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