Sha256: b6e8dd9a3894d44ce7dd50489666ff8815b163b78355fc1da508e62b23eb576b

Contents?: true

Size: 835 Bytes

Versions: 1

Compression:

Stored size: 835 Bytes

Contents

require 'nano/time/stamp'

require 'glue/aspects'

module Glue

# Adds timestamping functionality.

module Timestamped
  include Aspects

  property :create_time, Time, :editor => :none
  property :update_time, Time, :editor => :none
  property :access_time, Time, :editor => :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, :editor => :none
  before "@create_time = @update_time = Time.now", :on => :og_insert
end

end

# * George Moschovitis <gm@navel.gr>

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
og-0.25.0 lib/glue/timestamped.rb