module MongoMapper::Plugins::Touch

Public Instance Methods

touch(key = :updated_at) click to toggle source
# File lib/mongo_mapper/plugins/touch.rb, line 6
def touch(key = :updated_at)
  raise ArgumentError, "Invalid key named #{key}" unless self.key_names.include?(key.to_s)
  if self.class.embeddable?
    self.write_attribute(key, Time.now.utc)
    self._parent_document.touch
  else
    self.set(key => Time.now.utc)
  end
  true
end