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

Instance Method Details

#_clear_timeliness_cacheObject



88
89
90
# File 'lib/validates_timeliness/attribute_methods.rb', line 88

def _clear_timeliness_cache
  @timeliness_cache = {}
end

#read_timeliness_attribute_before_type_cast(attr_name) ⇒ Object



84
85
86
# File 'lib/validates_timeliness/attribute_methods.rb', line 84

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



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/validates_timeliness/attribute_methods.rb', line 72

def write_timeliness_attribute(attr_name, value)
  @timeliness_cache ||= {}
  @timeliness_cache[attr_name] = value

  if ValidatesTimeliness.use_plugin_parser
    timezone = :current if self.class.timeliness_attribute_timezone_aware?(attr_name)
    value = Timeliness::Parser.parse(value, self.class.timeliness_attribute_type(attr_name), :zone => timezone)
  end

  @attributes[attr_name] = value
end