Module: Recliner::Timestamps
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/recliner/timestamps.rb
Overview
Recliner automatically timestamps create and update operations if the document has properties named created_at/created_on or updated_at/updated_on.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #create_with_timestamps ⇒ Object
- #save_with_timestamps(*args) ⇒ Object
- #save_with_timestamps!(*args) ⇒ Object
Instance Method Details
#create_with_timestamps ⇒ Object
36 37 38 39 40 41 |
# File 'lib/recliner/timestamps.rb', line 36 def write_attribute(:created_at, Time.now) if properties.include?(:created_at) write_attribute(:created_on, Time.now) if properties.include?(:created_on) end |
#save_with_timestamps(*args) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/recliner/timestamps.rb', line 22 def (*args) write_attribute(:updated_at, Time.now) if properties.include?(:updated_at) write_attribute(:updated_on, Time.now) if properties.include?(:updated_on) (*args) end |
#save_with_timestamps!(*args) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/recliner/timestamps.rb', line 29 def (*args) write_attribute(:updated_at, Time.now) if properties.include?(:updated_at) write_attribute(:updated_on, Time.now) if properties.include?(:updated_on) (*args) end |