Module: EachBatch::ActiveRecord::Relation
- Defined in:
- lib/each_batch/active_record/relation.rb
Instance Method Summary collapse
-
#each_batch(of: 1000, load: false, order: :asc, keys: [primary_key]) {|x| ... } ⇒ EachBatch::BatchEnumerator
Process records in batches.
Instance Method Details
#each_batch(of: 1000, load: false, order: :asc, keys: [primary_key]) {|x| ... } ⇒ EachBatch::BatchEnumerator
Process records in batches. Optionally specify the keys by which to calculate the batch offsets.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/each_batch/active_record/relation.rb', line 19 def each_batch(of: 1000, load: false, order: :asc, keys: [primary_key], &block) batch_enumerator = ::EachBatch::BatchEnumerator.new( self, of: of, load: load, order: order, keys: keys ) return batch_enumerator unless block_given? batch_enumerator.each(&block) end |