Module: CouchPotato::MagicTimestamps

Defined in:
lib/couch_potato/persistence/magic_timestamps.rb

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/couch_potato/persistence/magic_timestamps.rb', line 3

def self.included(base)
  base.instance_eval do
    property :created_at, :type => Time
    property :updated_at, :type => Time
    
    before_create lambda {|model| model.created_at = Time.now; model.created_at_not_changed}
    before_save lambda {|model| model.updated_at = Time.now; model.updated_at_not_changed}
  end
end