Sha256: e2e5d6e8c9366a623fd7652bcd1f179d052c9475bb186642ff2f75feb1542ce1

Contents?: true

Size: 788 Bytes

Versions: 6

Compression:

Stored size: 788 Bytes

Contents

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

    # Contains common logic for delete operations.
    module Deletion

      # Wrap all the common delete logic for both root and embedded
      # documents and then yield to the block.
      #
      # @example Execute common delete logic.
      #   prepare do |doc|
      #     collection.remove({ :_id => "value })
      #   end
      #
      # @param [ Proc ] block The block to call.
      #
      # @return [ true ] Always true.
      #
      # @since 2.1.0
      def prepare(&block)
        document.cascade!
        yield(document)
        document.freeze
        document.destroyed = true
        IdentityMap.remove(document)
        Threaded.clear_safety_options!
        true
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-2.2.6 lib/mongoid/persistence/deletion.rb
mongoid-2.2.5 lib/mongoid/persistence/deletion.rb
mongoid-2.2.4 lib/mongoid/persistence/deletion.rb
mongoid-2.2.3 lib/mongoid/persistence/deletion.rb
mongoid-2.2.2 lib/mongoid/persistence/deletion.rb
mongoid-2.2.1 lib/mongoid/persistence/deletion.rb