Sha256: 6ff8e7176c9680e217d44225ff13e47cf3e1594877669cd3716edceeed302ad7
Contents?: true
Size: 665 Bytes
Versions: 13
Compression:
Stored size: 665 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.to_s super end protected def write self.updated_at = Time.now.utc.to_s super end end end
Version data entries
13 entries across 13 versions & 1 rubygems