Module: Redis::Actions::Timestamps

Defined in:
lib/redis/actions/timestamps.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/redis/actions/timestamps.rb', line 10

def self.included(base)
  base.instance_eval do
    attribute :created_at
    attribute :updated_at
    
    before_save   :updated_at_timestamp
    before_create :created_at_timestamp
  end
end

Instance Method Details

#created_at_timestampObject



6
7
8
# File 'lib/redis/actions/timestamps.rb', line 6

def created_at_timestamp
  self.created_at ||= Time.now
end

#updated_at_timestampObject



2
3
4
# File 'lib/redis/actions/timestamps.rb', line 2

def updated_at_timestamp
  self.updated_at = Time.now
end