Sha256: e194b18ac864c2b0279be0aafedba04ac7ef8c36ab5a249fe410e89298a761d3

Contents?: true

Size: 873 Bytes

Versions: 2

Compression:

Stored size: 873 Bytes

Contents

require 'facet/time/stamp'
require 'facets/more/aspects'

module Glue

# Adds timestamping functionality.
#--
# TODO: add an initialize method that inits times 
# before saving?
#++

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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
og-0.41.0 lib/glue/timestamped.rb
og-0.40.0 lib/glue/timestamped.rb