module Mongoid::Timestamps::Updated
This module handles the behavior for setting up document updated at timestamp.
Public Instance Methods
able_to_set_updated_at?()
click to toggle source
Is the updated timestamp able to be set?
@example Can the timestamp be set?
document.able_to_set_updated_at?
@return [ true, false ] If the timestamp can be set.
@since 2.4.0
# File lib/mongoid/timestamps/updated.rb, line 42 def able_to_set_updated_at? !frozen? && !timeless? && (new_record? || changed?) end
set_updated_at()
click to toggle source
Update the updated_at field on the Document
to the current time. This is only called on create and on save.
@example Set the updated at time.
person.set_updated_at
# File lib/mongoid/timestamps/updated.rb, line 26 def set_updated_at if able_to_set_updated_at? self.updated_at = Time.now.utc unless updated_at_changed? end clear_timeless_option end