From 5becd7886be7468767035de9ffced7b338f07b9c Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Fri, 14 Sep 2012 18:44:35 +1000 Subject: [PATCH] Removing silly class variables from config module --- lib/validates_timeliness.rb | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/lib/validates_timeliness.rb b/lib/validates_timeliness.rb index bb05b9a..fbb9a14 100644 --- a/lib/validates_timeliness.rb +++ b/lib/validates_timeliness.rb @@ -24,26 +24,24 @@ module ValidatesTimeliness class << self delegate :default_timezone, :default_timezone=, :dummy_date_for_time_type, :dummy_date_for_time_type=, :to => Timeliness + + attr_accessor :extend_orms, :ignore_restriction_errors, :restriction_shorthand_symbols, :use_plugin_parser end # Extend ORM/ODMs for full support (:active_record, :mongoid). - mattr_accessor :extend_orms - @@extend_orms = [] + self.extend_orms = [] # Ignore errors when restriction options are evaluated - mattr_accessor :ignore_restriction_errors - @@ignore_restriction_errors = false + self.ignore_restriction_errors = false # Shorthand time and date symbols for restrictions - mattr_accessor :restriction_shorthand_symbols - @@restriction_shorthand_symbols = { + self.restriction_shorthand_symbols = { :now => lambda { Time.current }, :today => lambda { Date.current } } # Use the plugin date/time parser which is stricter and extensible - mattr_accessor :use_plugin_parser - @@use_plugin_parser = false + self.use_plugin_parser = false # Default timezone self.default_timezone = :utc @@ -51,10 +49,6 @@ module ValidatesTimeliness # Set the dummy date part for a time type values. self.dummy_date_for_time_type = [ 2000, 1, 1 ] - def self.parser - Timeliness - end - # Setup method for plugin configuration def self.setup yield self @@ -64,6 +58,8 @@ module ValidatesTimeliness def self.load_orms extend_orms.each {|orm| require "validates_timeliness/orm/#{orm}" } end + + def self.parser; Timeliness end end require 'validates_timeliness/conversion'