class ActiveRecord::Batches::BatchEnumerator

def destroy_all

See Relation#destroy_all for details of how each batch is destroyed.

Person.where("age < 10").in_batches.destroy_all

Destroys records in batches. Returns the total number of rows affected.
def destroy_all
  sum do |relation|
    relation.destroy_all.count(&:destroyed?)
  end
end