From a56cf674b2c7bec92314856f2ffc46da34d6fc98 Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Sun, 7 Jun 2009 08:21:46 +1000 Subject: [PATCH] removed reload alias by attributes_cache for before_type_cast value --- .../active_record/attribute_methods.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/validates_timeliness/active_record/attribute_methods.rb b/lib/validates_timeliness/active_record/attribute_methods.rb index 8034115..7a2f66d 100644 --- a/lib/validates_timeliness/active_record/attribute_methods.rb +++ b/lib/validates_timeliness/active_record/attribute_methods.rb @@ -15,7 +15,6 @@ module ValidatesTimeliness def self.included(base) base.extend ClassMethods base.class_eval do - alias_method_chain :reload, :timeliness alias_method_chain :read_attribute_before_type_cast, :timeliness class << self alias_method_chain :define_attribute_methods, :timeliness @@ -24,7 +23,7 @@ module ValidatesTimeliness end def write_date_time_attribute(attr_name, value, type, time_zone_aware) - @attributes["_#{attr_name}_before_type_cast"] = value + @attributes_cache["_#{attr_name}_before_type_cast"] = value new = ValidatesTimeliness::Parser.parse(value, type) @@ -37,15 +36,10 @@ module ValidatesTimeliness end def read_attribute_before_type_cast_with_timeliness(attr_name) - return @attributes["_#{attr_name}_before_type_cast"] if @attributes.has_key?("_#{attr_name}_before_type_cast") + return @attributes_cache["_#{attr_name}_before_type_cast"] if @attributes_cache.has_key?("_#{attr_name}_before_type_cast") read_attribute_before_type_cast_without_timeliness(attr_name) end - def reload_with_timeliness - @attributes.keys.grep(/^_.*_before_type_cast$/).each { |key| @attributes.delete(key) } - reload_without_timeliness - end - module ClassMethods def define_attribute_methods_with_timeliness