Module: ValidatesTimeliness::AttributeMethods
- Extended by:
- ActiveSupport::Concern
- Included in:
- ActiveRecord::Base
- Defined in:
- lib/validates_timeliness/attribute_methods.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #_clear_timeliness_cache ⇒ Object
- #read_timeliness_attribute_before_type_cast(attr_name) ⇒ Object
- #write_timeliness_attribute(attr_name, value) ⇒ Object
Instance Method Details
#_clear_timeliness_cache ⇒ Object
84 85 86 |
# File 'lib/validates_timeliness/attribute_methods.rb', line 84 def _clear_timeliness_cache @timeliness_cache = {} end |
#read_timeliness_attribute_before_type_cast(attr_name) ⇒ Object
80 81 82 |
# File 'lib/validates_timeliness/attribute_methods.rb', line 80 def read_timeliness_attribute_before_type_cast(attr_name) @timeliness_cache && @timeliness_cache[attr_name] || @attributes[attr_name] end |
#write_timeliness_attribute(attr_name, value) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/validates_timeliness/attribute_methods.rb', line 66 def write_timeliness_attribute(attr_name, value) @timeliness_cache ||= {} @timeliness_cache[attr_name] = value if ValidatesTimeliness.use_plugin_parser type = self.class.timeliness_attribute_type(attr_name) timezone = :current if self.class.timeliness_attribute_timezone_aware?(attr_name) value = Timeliness::Parser.parse(value, type, :zone => timezone) value = value.to_date if value && type == :date end @attributes[attr_name] = value end |