mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-24 23:06:42 +00:00
little tweaks
This commit is contained in:
parent
687e61a3f2
commit
a969a49ae8
@ -36,7 +36,8 @@ module ValidatesTimeliness
|
|||||||
end
|
end
|
||||||
|
|
||||||
def read_attribute_before_type_cast_with_timeliness(attr_name)
|
def read_attribute_before_type_cast_with_timeliness(attr_name)
|
||||||
return @attributes_cache["_#{attr_name}_before_type_cast"] if @attributes_cache.has_key?("_#{attr_name}_before_type_cast")
|
cached_attr = "_#{attr_name}_before_type_cast"
|
||||||
|
return @attributes_cache[cached_attr] if @attributes_cache.has_key?(cached_attr)
|
||||||
read_attribute_before_type_cast_without_timeliness(attr_name)
|
read_attribute_before_type_cast_without_timeliness(attr_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -50,11 +51,9 @@ module ValidatesTimeliness
|
|||||||
if [:date, :time, :datetime].include?(column.type)
|
if [:date, :time, :datetime].include?(column.type)
|
||||||
time_zone_aware = create_time_zone_conversion_attribute?(name, column) rescue false
|
time_zone_aware = create_time_zone_conversion_attribute?(name, column) rescue false
|
||||||
|
|
||||||
class_eval <<-EOV
|
define_method("#{name}=") do |value|
|
||||||
def #{name}=(value)
|
write_date_time_attribute(name, value, column.type, time_zone_aware)
|
||||||
write_date_time_attribute('#{name}', value, #{column.type.inspect}, #{time_zone_aware})
|
|
||||||
end
|
end
|
||||||
EOV
|
|
||||||
timeliness_methods << name
|
timeliness_methods << name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user