Sha256: 499cb419b85f756e882e929937fdc4a6b18ce2fb54dbb82aba738564cb4ef4f5

Contents?: true

Size: 555 Bytes

Versions: 5

Compression:

Stored size: 555 Bytes

Contents

module CouchPotato
  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
          model.updated_at ||= Time.now
          model.updated_at_not_changed
        }
        before_update lambda {|model|
          model.updated_at = Time.now
          model.updated_at_not_changed}
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
couch_potato-0.3.2 lib/couch_potato/persistence/magic_timestamps.rb
couch_potato-0.3.1 lib/couch_potato/persistence/magic_timestamps.rb
davber_couch_potato-0.3.0 lib/couch_potato/persistence/magic_timestamps.rb
couch_potato-0.3.0 lib/couch_potato/persistence/magic_timestamps.rb
couch_potato-0.2.32 lib/couch_potato/persistence/magic_timestamps.rb