Module: Mongoid::Timestamps::Updated
- Extended by:
- ActiveSupport::Concern
- Included in:
- Mongoid::Timestamps
- Defined in:
- lib/mongoid/timestamps/updated.rb,
lib/mongoid/timestamps/updated/short.rb
Overview
This module handles the behaviour for setting up document updated at timestamp.
Defined Under Namespace
Modules: Short
Instance Method Summary collapse
-
#able_to_set_updated_at? ⇒ true, false
Is the updated timestamp able to be set?.
-
#set_updated_at ⇒ Object
Update the updated_at field on the Document to the current time.
Instance Method Details
#able_to_set_updated_at? ⇒ true, false
Is the updated timestamp able to be set?
34 35 36 |
# File 'lib/mongoid/timestamps/updated.rb', line 34 def able_to_set_updated_at? !frozen? && (new_record? || changed?) end |
#set_updated_at ⇒ Object
Update the updated_at field on the Document to the current time. This is only called on create and on save.
22 23 24 |
# File 'lib/mongoid/timestamps/updated.rb', line 22 def set_updated_at self.updated_at = Time.now.utc unless updated_at_changed? end |