Module: MotionPrime::ModelTimestampsMixin::ClassMethods

Defined in:
motion-prime/models/_timestamps_mixin.rb

Instance Method Summary collapse

Instance Method Details

#timestamp_attributes(actions = nil) ⇒ Object



23
24
25
26
27
28
29
30
# File 'motion-prime/models/_timestamps_mixin.rb', line 23

def timestamp_attributes(actions = nil)
  self._timestamp_attributes ||= {}
  actions ||= {save: :saved_at, create: :created_at}
  actions.each do |action_name, field|
    self._timestamp_attributes[action_name.to_sym] = field
    self.attribute field, type: :time
  end
end