Sha256: 1ca288097e8f5de4d868701f10bab377973bef82a8d8f3c3cc0120c3bd8f44c3

Contents?: true

Size: 450 Bytes

Versions: 12

Compression:

Stored size: 450 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

12 entries across 12 versions & 1 rubygems

Version Path
mongo_mapper-0.16.0 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.15.6 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.15.5 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.15.4 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.15.3 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.15.2 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.15.1 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.15.0 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.14.0 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.14.0.rc1 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.13.1 lib/mongo_mapper/plugins/touch.rb
mongo_mapper-0.13.0 lib/mongo_mapper/plugins/touch.rb