Sha256: 78018f1dd30fdf34c0717ee2793841578b0a18a635715cd191e53231a025dfd0

Contents?: true

Size: 1012 Bytes

Versions: 4

Compression:

Stored size: 1012 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Persistence #:nodoc:
    # Remove is a persistence command responsible for deleting a document from
    # the database.
    #
    # The underlying query resembles the following MongoDB query:
    #
    #   collection.remove(
    #     { "_id" : 1 },
    #     false
    #   );
    class Remove < Command
      # Remove the document from the database: delegates to the MongoDB
      # collection remove method.
      #
      # Example:
      #
      # <tt>Remove.persist</tt>
      #
      # Returns:
      #
      # +true+ if success, +false+ if not.
      def persist
        remove
      end

      protected
      # Remove the document from the database.
      def remove
        if @document.embedded?
          Persistence::RemoveEmbedded.new(
            @document,
            @options.merge(:validate => @validate)
          ).persist
        else
          @collection.remove({ :_id => @document.id }, @options)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mongoid-2.0.0.beta.14 lib/mongoid/persistence/remove.rb
mongoid-2.0.0.beta.13 lib/mongoid/persistence/remove.rb
mongoid-2.0.0.beta.11 lib/mongoid/persistence/remove.rb
mongoid-2.0.0.beta.12 lib/mongoid/persistence/remove.rb