Module: CouchTomato::Persistence::MagicTimestamps

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

Overview

:nodoc:

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



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

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