Sha256: 4e29869b5a3b24e7dfc2cd929accd65568df854f812b811f405a06309db8cb7a
Contents?: true
Size: 654 Bytes
Versions: 3
Compression:
Stored size: 654 Bytes
Contents
module Ohm # Provides created_at / updated_at timestamps. # # @example # # class Post < Ohm::Model # include Ohm::Timestamping # end # # post = Post.create # post.created_at.to_s == Time.now.utc.to_s # # => true # # post = Post[post.id] # post.save # post.updated_at.to_s == Time.now.utc.to_s # # => true module Timestamping def self.included(base) base.attribute :created_at base.attribute :updated_at end def create self.created_at ||= Time.now.utc super end protected def write self.updated_at = Time.now.utc super end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ohm-contrib-0.0.29 | lib/ohm/contrib/timestamping.rb |
ohm-contrib-0.0.28 | lib/ohm/contrib/timestamping.rb |
ohm-contrib-0.0.27 | lib/ohm/contrib/timestamping.rb |