module Mongoid::Persistence::Deletion

Contains common logic for delete operations.

Public Instance Methods

prepare() { |document| ... } click to toggle source

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

# File lib/mongoid/persistence/deletion.rb, line 20
def prepare(&block)
  document.cascade!
  yield(document)
  document.freeze
  document.destroyed = true
  IdentityMap.remove(document)
  Threaded.clear_options!
  true
end