Module: Superstore::Relation::Scrolling
- Defined in:
- lib/superstore/relation/scrolling.rb
Instance Method Summary collapse
Instance Method Details
#scroll_each(options = {}) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/superstore/relation/scrolling.rb', line 4 def scroll_each( = {}) batch_size = [:batch_size] || 1000 scroll_results(batch_size) do |attributes| yield klass.instantiate(attributes) end end |
#scroll_in_batches(options = {}) {|batch| ... } ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/superstore/relation/scrolling.rb', line 12 def scroll_in_batches( = {}) batch_size = [:batch_size] || 1000 batch = [] scroll_each() do |record| batch << record if batch.size == batch_size yield batch batch = [] end end yield(batch) if batch.any? end |