instance method
batch_on_loaded_relation
Ruby on Rails 7.1.6
Since v7.1.6 PrivateSignature
batch_on_loaded_relation(relation:, start:, finish:, order:, batch_limit:)
No documentation comment.
Parameters
-
relationkeyreq -
startkeyreq -
finishkeyreq -
orderkeyreq -
batch_limitkeyreq
Source
# File activerecord/lib/active_record/relation/batches.rb, line 339
def batch_on_loaded_relation(relation:, start:, finish:, order:, batch_limit:)
records = relation.to_a
if start || finish
records = records.filter do |record|
(start.nil? || record.id >= start) && (finish.nil? || record.id <= finish)
end
end
records = records.sort_by { |record| record.id }
if order == :desc
records.reverse!
end
(0...records.size).step(batch_limit).each do |start|
subrelation = relation.spawn
subrelation.load_records(records[start, batch_limit])
yield subrelation
end
nil
end
Defined in activerecord/lib/active_record/relation/batches.rb line 339
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Batches