Sha256: 3ebda212b5c4c22f2618ffff7a2113ad08d4f909f6355994303621969340a9b3

Contents?: true

Size: 955 Bytes

Versions: 188

Compression:

Stored size: 955 Bytes

Contents

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

      # Insert is a persistence command responsible for taking a document that
      # has not been saved to the database and saving it.
      #
      # The underlying query resembles the following MongoDB query:
      #
      #   collection.insert(
      #     { "_id" : 1, "field" : "value" },
      #     false
      #   );
      class Insert
        include Insertion, Operations

        # Insert the new document in the database. This delegates to the standard
        # MongoDB collection's insert command.
        #
        # @example Insert the document.
        #   Insert.persist
        #
        # @return [ Document ] The document to be inserted.
        def persist
          prepare do |doc|
            collection.insert(doc.as_document, options)
            IdentityMap.set(doc)
          end
        end
      end
    end
  end
end

Version data entries

188 entries across 96 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/operations/insert.rb
mongoid-2.8.1 lib/mongoid/persistence/operations/insert.rb
mongoid-2.8.0 lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/persistence/operations/insert.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/persistence/operations/insert.rb