Sha256: 775c725c940c49495d395272504c4a415b4aef58d6ee6867b9646dd02efa0d90
Contents?: true
Size: 488 Bytes
Versions: 63
Compression:
Stored size: 488 Bytes
Contents
# encoding: UTF-8 module MongoMapper module Plugins module Timestamps module ClassMethods def timestamps! key :created_at, Time key :updated_at, Time class_eval { before_save :update_timestamps } end end module InstanceMethods def update_timestamps now = Time.now.utc self[:created_at] = now if new? && !created_at? self[:updated_at] = now end end end end end
Version data entries
63 entries across 63 versions & 9 rubygems
Version | Path |
---|---|
mongo_mapper-0.8.0 | lib/mongo_mapper/plugins/timestamps.rb |
pwnash-mongo_mapper-0.7.6 | lib/mongo_mapper/plugins/timestamps.rb |
mongo_mapper_ign-0.7.6 | lib/mongo_mapper/plugins/timestamps.rb |