Module: Reorm::Timestamped

Defined in:
lib/reorm/modules/database_modules.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(target) ⇒ Object



62
63
64
65
# File 'lib/reorm/modules/database_modules.rb', line 62

def Timestamped.included(target)
  target.before_create :set_created_at
  target.before_update :set_updated_at
end

Instance Method Details

#set_created_atObject



53
54
55
56
# File 'lib/reorm/modules/database_modules.rb', line 53

def set_created_at
  self.created_at = Time.now
  self.updated_at = nil
end

#set_updated_atObject



58
59
60
# File 'lib/reorm/modules/database_modules.rb', line 58

def set_updated_at
  self.updated_at = Time.now
end