Sha256: 1f2288020990e1f57597a3a00481079fdd85b4d58fe45d6a32996ba0fe825f15

Contents?: true

Size: 919 Bytes

Versions: 32

Compression:

Stored size: 919 Bytes

Contents

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

      # 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)
            IdentityMap.set(doc)
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
mongoid-3.1.7 lib/mongoid/persistence/operations/insert.rb
mongoid-3.1.6 lib/mongoid/persistence/operations/insert.rb
mongoid-3.1.5 lib/mongoid/persistence/operations/insert.rb
mongoid-3.1.4 lib/mongoid/persistence/operations/insert.rb
mongoid-3.1.3 lib/mongoid/persistence/operations/insert.rb
mongoid-3.1.2 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.23 lib/mongoid/persistence/operations/insert.rb
mongoid-3.1.1 lib/mongoid/persistence/operations/insert.rb
mongoid-3.1.0 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.22 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.21 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.20 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.19 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.18 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.17 lib/mongoid/persistence/operations/insert.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.16/lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.16 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.15 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.14 lib/mongoid/persistence/operations/insert.rb
mongoid-3.0.13 lib/mongoid/persistence/operations/insert.rb