Module: DataMapper::Timestamp

Defined in:
lib/gems/dm-timestamps-0.9.9/lib/dm-timestamps.rb

Defined Under Namespace

Modules: ClassMethods Classes: InvalidTimestampName

Constant Summary collapse

TIMESTAMP_PROPERTIES =
{
  :updated_at => [ DateTime, lambda { |r, p| DateTime.now                                    } ],
  :updated_on => [ Date,     lambda { |r, p| Date.today                                      } ],
  :created_at => [ DateTime, lambda { |r, p| r.created_at || (DateTime.now if r.new_record?) } ],
  :created_on => [ Date,     lambda { |r, p| r.created_on || (Date.today   if r.new_record?) } ],
}.freeze

Class Method Summary collapse

Class Method Details

.included(model) ⇒ Object



17
18
19
20
21
# File 'lib/gems/dm-timestamps-0.9.9/lib/dm-timestamps.rb', line 17

def self.included(model)
  model.before :create, :set_timestamps
  model.before :update, :set_timestamps
  model.extend ClassMethods
end