removed reload alias by attributes_cache for before_type_cast value

This commit is contained in:
Adam Meehan 2009-06-07 08:21:46 +10:00
parent 7f4d7b38d7
commit a56cf674b2

View File

@ -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