Module: NoBrainer::Document::Timestamps
- Extended by:
- ActiveSupport::Concern
- Included in:
- Index::MetaStore
- Defined in:
- lib/no_brainer/document/timestamps.rb
Instance Method Summary collapse
Instance Method Details
#_create(options = {}) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/no_brainer/document/timestamps.rb', line 9 def _create(={}) now = Time.now self.created_at = now unless created_at_changed? self.updated_at = now unless updated_at_changed? super end |
#_update(attrs) ⇒ Object
16 17 18 19 |
# File 'lib/no_brainer/document/timestamps.rb', line 16 def _update(attrs) self.updated_at = Time.now unless updated_at_changed? super(attrs.merge('updated_at' => @_attributes['updated_at'])) end |
#cache_key ⇒ Object
21 22 23 |
# File 'lib/no_brainer/document/timestamps.rb', line 21 def cache_key "#{super}#{updated_at.try(:strftime, "-%s%L")}" end |
#touch ⇒ Object
25 26 27 |
# File 'lib/no_brainer/document/timestamps.rb', line 25 def touch update!(:updated_at => Time.now) end |