Sha256: e614b10a6114f1873604c8d45e96ea7f8c492b14db7214dc829362e132245145

Contents?: true

Size: 338 Bytes

Versions: 3

Compression:

Stored size: 338 Bytes

Contents

motion_require 'document.rb'

module Yapper::Timestamps
  extend MotionSupport::Concern

  included do
    field :updated_at, :type => Time
    field :created_at, :type => Time

    before_save :set_timestamps
  end

  def set_timestamps
    now = Time.now
    self.created_at = now if created_at.nil?
    self.updated_at = now
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
motion-yapper-0.1.0 lib/yapper/timestamps.rb
motion-yapper-0.0.3 lib/yapper/timestamps.rb
motion-yapper-0.0.2 lib/yapper/timestamps.rb