def active_record_enumeration(records, io, options)
if !records.respond_to?(:arel) || records.arel.orders.blank?
records.order("#{records.quoted_table_name}.#{records.quoted_primary_key} ASC")
end
num_of_batches, batch_size, last_batch_size = batch_params_from(records, options)
(1..num_of_batches).each do |batch_number|
record_strings = []
last_batch = (batch_number == num_of_batches)
cur_batch_size = if last_batch
last_batch_size
else
batch_size
end
records.offset((batch_number - 1) * batch_size).limit(cur_batch_size).each do |record|
record_strings << dump_record(record, options)
end
yield record_strings, last_batch
end
end