# File lib/dm-timestamps.rb, line 12
12: defself.included(model)
13: model.before:save, :set_timestamps_on_save
14: model.extendClassMethods
15: end
Public Instance Methods
touch()click to toggle source
Saves the record with the updated_at/on attributes set to the current time.
# File lib/dm-timestamps.rb, line 18
18: deftouch
19: set_timestamps
20: save
21: end
Private Instance Methods
set_timestamps()click to toggle source
# File lib/dm-timestamps.rb, line 30
30: defset_timestamps
31: TIMESTAMP_PROPERTIES.eachdo|name,(_type,proc)|
32: ifproperties.named?(name)
33: attribute_set(name, proc.call(self))
34: end
35: end
36: end
set_timestamps_on_save()click to toggle source
# File lib/dm-timestamps.rb, line 25
25: defset_timestamps_on_save
26: returnunlessdirty?
27: set_timestamps
28: end