Sha256: 71bdfb2cde77056778a679383475a3a4d89e9ecd0dda2010bb255d2ea510c2dd
Contents?: true
Size: 655 Bytes
Versions: 10
Compression:
Stored size: 655 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
10 entries across 10 versions & 1 rubygems