Module: DataMapper::Timestamps
- Defined in:
- lib/dm-timestamps.rb
Defined Under Namespace
Modules: ClassMethods Classes: InvalidTimestampName
Constant Summary collapse
- TIMESTAMP_PROPERTIES =
{ :updated_at => [ DateTime, lambda { |r| DateTime.now } ], :updated_on => [ Date, lambda { |r| Date.today } ], :created_at => [ DateTime, lambda { |r| r.created_at || (DateTime.now if r.new?) } ], :created_on => [ Date, lambda { |r| r.created_on || (Date.today if r.new?) } ], }.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#touch ⇒ Object
Saves the record with the updated_at/on attributes set to the current time.
Class Method Details
.included(model) ⇒ Object
12 13 14 15 |
# File 'lib/dm-timestamps.rb', line 12 def self.included(model) model.before :save, :set_timestamps_on_save model.extend ClassMethods end |
Instance Method Details
#touch ⇒ Object
Saves the record with the updated_at/on attributes set to the current time.
18 19 20 21 |
# File 'lib/dm-timestamps.rb', line 18 def touch save end |