Sha256: 2bd4f7c34fbe6c4f38b40bd6e7126ba21f5ebecf55d3022454236f22b9c9252d

Contents?: true

Size: 725 Bytes

Versions: 31

Compression:

Stored size: 725 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Persistence
    module Operations

      # Wraps behaviour for performing upserts in Mongodb. No matter if the
      # document has been modified or not, it will be sent to the db and Mongo
      # will determin whether or not to insert or update.
      class Upsert
        include Upsertion, Operations

        # Persist the upsert operation.
        #
        # @example Execute the upsert.
        #   operation.persist
        #
        # @return [ true ] Always true.
        #
        # @since 3.0.0
        def persist
          prepare do
            collection.find(selector).update(document.as_document, [ :upsert ])
          end
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
mongoid-3.0.12 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.11 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.10 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.9 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.6 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.5 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.4 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.3 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.2 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.1 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.0 lib/mongoid/persistence/operations/upsert.rb