Sha256: 5d9fe431e78b930b3cdf253bfe003be026b0cc9904e6565e7acb87169c93e006

Contents?: true

Size: 451 Bytes

Versions: 7

Compression:

Stored size: 451 Bytes

Contents

module MongoMapper
  module Plugins
    module Touch
      extend ActiveSupport::Concern

      def touch(key = :updated_at) 
        raise ArgumentError, "Invalid key named #{key}" unless self.key_names.include?(key.to_s)
        if self.class.embeddable?
          self.write_attribute(key, Time.now.utc)
          self._parent_document.touch
        else
          self.set(key => Time.now.utc)
        end
        true
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
mongo_mapper-0.13.0.beta2 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.13.0.beta1 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.12.0 lib/mongo_mapper/plugins/touch.rb
lookout-mongo_mapper-0.11.3 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.11.2 lib/mongo_mapper/plugins/touch.rb
jamieorc-mongo_mapper-0.11.1.1 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.11.1 lib/mongo_mapper/plugins/touch.rb