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.1.7 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.1.6 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.1.5 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.1.4 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.1.3 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.1.2 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.23 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.1.1 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.1.0 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.22 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.21 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.20 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.19 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.18 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.17 lib/mongoid/persistence/operations/upsert.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.16/lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.16 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.15 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.14 lib/mongoid/persistence/operations/upsert.rb
mongoid-3.0.13 lib/mongoid/persistence/operations/upsert.rb