Sha256: f3522c1ae34467a77e87d29d6bc2256cb5638a0bc3923b1ebf13198652a0e6b3

Contents?: true

Size: 824 Bytes

Versions: 2

Compression:

Stored size: 824 Bytes

Contents

require 'nano/time/stamp'

require 'glue/aspects'

module Glue

# Adds timestamping functionality.

module Timestamped
  include Aspects

  property :create_time, Time, :control => :none
  property :update_time, Time, :control => :none
  property :access_time, Time, :control => :none

  before "@create_time = @update_time = Time.now", :on => :og_insert
  before "@update_time = Time.now", :on => :og_update

  def touch!
    @access_time = Time.now
  end
end

# Adds simple timestamping functionality on create.
# Only the create_time field is added, to add 
# create/update/access fields use the normal timestamped
# module.

module TimestampedOnCreate
  include Aspects
  property :create_time, Time, :control => :none
  before "@create_time = Time.now", :on => :og_insert
end

end

# * George Moschovitis <gm@navel.gr>

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.26.0 lib/glue/timestamped.rb
og-0.27.0 lib/glue/timestamped.rb