Sha256: 3f8bf5af0b3836f17d870065e30e2ced6328af1848654fa347ecb9cb7290d535

Contents?: true

Size: 476 Bytes

Versions: 7

Compression:

Stored size: 476 Bytes

Contents

module CouchTomato
  module Persistence
    module MagicTimestamps #:nodoc:
      def self.included(base)
        base.instance_eval do
          property :created_at, :type => Time
          property :updated_at, :type => Time
        
          before_create lambda {|model| model.created_at = Time.now; model.created_at_not_changed}
          before_save lambda {|model| model.updated_at = Time.now; model.updated_at_not_changed}
        end
      end
    end    
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
couch_tomato-0.2.0 lib/couch_tomato/persistence/magic_timestamps.rb
couch_tomato-0.1.5 lib/couch_tomato/persistence/magic_timestamps.rb
couch_tomato-0.1.4 lib/couch_tomato/persistence/magic_timestamps.rb
couch_tomato-0.1.3 lib/couch_tomato/persistence/magic_timestamps.rb
couch_tomato-0.1.2 lib/couch_tomato/persistence/magic_timestamps.rb
couch_tomato-0.1.1 lib/couch_tomato/persistence/magic_timestamps.rb
couch_tomato-0.1.0 lib/couch_tomato/persistence/magic_timestamps.rb