class RubyEventStore::BatchEnumerator
Attributes
Public Class Methods
Source
# File lib/ruby_event_store/batch_enumerator.rb, line 5 def initialize(batch_size, total_limit, reader) @batch_size = batch_size @total_limit = total_limit @reader = reader end
Public Instance Methods
Source
# File lib/ruby_event_store/batch_enumerator.rb, line 11 def each return to_enum unless block_given? 0.step(total_limit - 1, batch_size) do |batch_offset| batch_limit = [batch_size, total_limit - batch_offset].min result = reader.call(batch_offset, batch_limit) yield result if result.any? break if result.size < batch_size end end