Module: SuperModel::Timestamp::Model

Defined in:
lib/supermodel/timestamp.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/supermodel/timestamp.rb', line 4

def self.included(base)
  base.class_eval do
    attributes :created_at, :updated_at
    
    before_create :set_created_at
    before_save   :set_updated_at
  end
end

Instance Method Details

#created_at=(time) ⇒ Object



18
19
20
# File 'lib/supermodel/timestamp.rb', line 18

def created_at=(time)
  write_attribute(:created_at, parse_time(time))
end

#touchObject



13
14
15
16
# File 'lib/supermodel/timestamp.rb', line 13

def touch
  set_updated_at
  save!
end

#updated_at=(time) ⇒ Object



22
23
24
# File 'lib/supermodel/timestamp.rb', line 22

def updated_at=(time)
  write_attribute(:updated_at, parse_time(time))
end