Method: EachBatch::BatchEnumerator#pluck

Defined in:
lib/each_batch/batch_enumerator.rb

#pluck(*pluck_keys) {|x| ... } ⇒ EachBatch::PluckedBatchEnumerator

Pluck selected columns in batches. The batching is the one specified on the { BatchEnumerator } instance.

Parameters:

  • pluck_keys (Array<Symbol, String>)

    The keys of the columns to pluck.

Yield Parameters:

  • x (Array<Object>)

    The array of the plucked values

Returns:



94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/each_batch/batch_enumerator.rb', line 94

def pluck(*pluck_keys, &block)
  plucked_batch_enumerator = ::EachBatch::PluckedBatchEnumerator.new(
    relation,
    of: batch_size,
    order: order,
    keys: keys,
    pluck_keys: pluck_keys.map(&:to_s)
  )

  return plucked_batch_enumerator unless block_given?

  plucked_batch_enumerator.each(&block)
end