module NoBrainer::Document::Timestamps

Public Instance Methods

_create(options={}) click to toggle source
Calls superclass method
# File lib/no_brainer/document/timestamps.rb, line 9
def _create(options={})
  now = Time.now
  self.created_at = now unless created_at_changed?
  self.updated_at = now unless updated_at_changed?
  super
end
_update(attrs) click to toggle source
Calls superclass method
# 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() click to toggle source
# File lib/no_brainer/document/timestamps.rb, line 21
def cache_key
  "#{super}#{updated_at.try(:strftime, "-%s%L")}"
end
touch() click to toggle source
# File lib/no_brainer/document/timestamps.rb, line 25
def touch
  update!(:updated_at => Time.now)
end