module Spira::Timestamps

Constants

VERSION

Public Class Methods

included(model) click to toggle source
# File lib/spira/timestamps.rb, line 8
def self.included(model)
  model.before_save :before_save
  model.extend ClassMethods
  model.timestamps
end

Public Instance Methods

touch() click to toggle source

Update this model's `updated` time without making any other changes.

# File lib/spira/timestamps.rb, line 15
def touch
  update_timestamps
  save
end

Private Instance Methods

before_save() click to toggle source
# File lib/spira/timestamps.rb, line 22
def before_save
  update_timestamps if changed?
end
update_timestamps() click to toggle source
# File lib/spira/timestamps.rb, line 26
def update_timestamps
  self.created = self.created || DateTime.now
  self.updated = DateTime.now
end