Sha256: 50e02305a41afb29a8e0db9adf627b41a8bc323cddfb2f85945da282d15e5a43
Contents?: true
Size: 777 Bytes
Versions: 1
Compression:
Stored size: 777 Bytes
Contents
module Pupa module Concerns # Adds the Popolo `created_at` and `updated_at` properties to a model. The # `created_at` and `updated_at` properties will automatically be set when # the object is inserted into or updated in the database. module Timestamps extend ActiveSupport::Concern included do attr_accessor :created_at, :updated_at dump :created_at, :updated_at set_callback(:create, :before) do |object| object.created_at = Time.now.utc end set_callback(:save, :before) do |object| # The object may not set created_at. object.created_at = object.document['created_at'] if object.document object.updated_at = Time.now.utc end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pupa-0.0.11 | lib/pupa/models/concerns/timestamps.rb |