Sha256: 264ef9c69218f4dceb5ea5d77dd78e97ddde70a8487efe38c9bee7be7acf4940

Contents?: true

Size: 788 Bytes

Versions: 11

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)
        yield(document)
        document.freeze
        document.destroyed = true
        document.cascade!
        IdentityMap.remove(document)
        Threaded.clear_safety_options!
        true
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mongoid-2.2.0 lib/mongoid/persistence/deletion.rb
mongoid-2.1.9 lib/mongoid/persistence/deletion.rb
mongoid-2.1.8 lib/mongoid/persistence/deletion.rb
mongoid-2.1.7 lib/mongoid/persistence/deletion.rb
mongoid-2.1.6 lib/mongoid/persistence/deletion.rb
mongoid-2.1.5 lib/mongoid/persistence/deletion.rb
mongoid-2.1.4 lib/mongoid/persistence/deletion.rb
mongoid-2.1.3 lib/mongoid/persistence/deletion.rb
mongoid-2.1.2 lib/mongoid/persistence/deletion.rb
mongoid-2.1.1 lib/mongoid/persistence/deletion.rb
mongoid-2.1.0 lib/mongoid/persistence/deletion.rb