Module: MongoBatch

Defined in:
lib/mongo_batch.rb

Defined Under Namespace

Classes: Batcher

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.in_batches(query, options = {}) ⇒ Object



38
39
40
# File 'lib/mongo_batch.rb', line 38

def self.in_batches(query, options = {})
  Batcher.new(query, options).batches
end

Instance Method Details

#find_in_batches(options = {}, &block) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/mongo_batch.rb', line 42

def find_in_batches(options = {}, &block)
  batcher = Batcher.new(self, options)

  if block
    batcher.batches.each(&block)
  else
    batcher.batches
  end
end