class RubyEventStore::BatchEnumerator
Attributes
batch_size[R]
reader[R]
total_limit[R]
Public Class Methods
new(batch_size, total_limit, reader)
click to toggle 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
each() { |result| ... }
click to toggle 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
first()
click to toggle source
# File lib/ruby_event_store/batch_enumerator.rb, line 23 def first each.first end
to_a()
click to toggle source
# File lib/ruby_event_store/batch_enumerator.rb, line 27 def to_a each.to_a end