Module: Ohm::Timestamping

Defined in:
lib/ohm/contrib/timestamping.rb

Overview

Provides created_at / updated_at timestamps.

Examples:

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) create



24
25
26
27
28
# File 'lib/ohm/contrib/timestamping.rb', line 24

def create
  self.created_at ||= Time.now.utc.to_s

  super
end