Module: ValidatesTimeliness::ORM::Mongoid

Extended by:
ActiveSupport::Concern
Included in:
Mongoid::Document
Defined in:
lib/validates_timeliness/orm/mongoid.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#_clear_timeliness_cacheObject



75
76
77
# File 'lib/validates_timeliness/orm/mongoid.rb', line 75

def _clear_timeliness_cache
  @timeliness_cache = {}
end

#read_timeliness_attribute_before_type_cast(attr_name) ⇒ Object



71
72
73
# File 'lib/validates_timeliness/orm/mongoid.rb', line 71

def read_timeliness_attribute_before_type_cast(attr_name)
  @timeliness_cache && @timeliness_cache[attr_name] || @attributes[attr_name]
end

#reload(*args) ⇒ Object



66
67
68
69
# File 'lib/validates_timeliness/orm/mongoid.rb', line 66

def reload(*args)
  _clear_timeliness_cache
  super
end

#write_timeliness_attribute(attr_name, value) ⇒ Object

This is needed in order to mark the attribute as changed; otherwise, mongoid won’t save it to the database.



61
62
63
64
# File 'lib/validates_timeliness/orm/mongoid.rb', line 61

def write_timeliness_attribute(attr_name, value)
  attribute_will_change!(database_field_name(attr_name))
  super
end