Module: Filemaker::Model::Batches

Defined in:
lib/filemaker/model/batches.rb

Instance Method Summary collapse

Instance Method Details

#in_batches(batch_size: 200, options: {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/filemaker/model/batches.rb', line 4

def in_batches(batch_size: 200, options: {})
  output = []
  total = where(options).count
  pages = (total / batch_size.to_f).ceil
  1.upto(pages) do |page|
    output.concat where(options).per(batch_size).page(page).all
  end

  output
end