Sha256: a27c66b9aa82ab8de9141c4d3f46268547940012db5660a25ab31c2465eaa2dd

Contents?: true

Size: 697 Bytes

Versions: 14

Compression:

Stored size: 697 Bytes

Contents

module EventSourcery
  module EventStore
    module EachByRange
      def each_by_range(from_event_id, to_event_id, event_types: nil)
        caught_up = false
        no_events_left = false
        event_id = from_event_id
        begin
          events = get_next_from(event_id, event_types: event_types)
          no_events_left = true if events.empty?
          events.each do |event|
            yield event
            if event.id == to_event_id
              caught_up = true
              break
            end
          end
          unless no_events_left
            event_id = events.last.id + 1
          end
        end while !caught_up && !no_events_left
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
event_sourcery-1.0.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.24.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.23.1 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.23.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.22.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.21.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.20.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.19.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.18.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.17.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.16.1 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.15.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.14.0 lib/event_sourcery/event_store/each_by_range.rb
event_sourcery-0.13.0 lib/event_sourcery/event_store/each_by_range.rb