Sha256: 3b502bab7b9937a4ada5ee1bdc62e90cd4fc848f2d6af2cc32f97e6f1fabfc23

Contents?: true

Size: 767 Bytes

Versions: 31

Compression:

Stored size: 767 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Commands
    class DestroyAll
      # Performs a destroy of the all the +Documents+ that match the criteria
      # supplied. Will execute all the destroy callbacks for each +Document+.
      #
      # Options:
      #
      # params: A set of conditions to find the +Documents+ by.
      # klass: The class of the +Document+ to execute the find on.
      #
      # Example:
      #
      # <tt>DestroyAll.execute(Person, :conditions => { :field => "value" })</tt>
      def self.execute(klass, params)
        conditions = params[:conditions] || {}
        params[:conditions] = conditions.merge(:_type => klass.name)
        klass.find(:all, params).each { |doc| Destroy.execute(doc) }
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 2 rubygems

Version Path
mongoid-0.12.0 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.9 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.8 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.7 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.6 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.5 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.4 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.3 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.2 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.1 lib/mongoid/commands/destroy_all.rb
mongoid-0.11.0 lib/mongoid/commands/destroy_all.rb