class EventStore::HTTP::Write::Substitute::Write
Constants
- Record
Attributes
version[RW]
Public Instance Methods
call(batch, stream, expected_version: nil)
click to toggle source
# File lib/event_store/http/write/substitute.rb, line 12 def call(batch, stream, expected_version: nil) if version && expected_version && version != expected_version raise ExpectedVersionError end if expected_version.nil? expected_version = -1 stream_version = version || -1 else stream_version = expected_version end path = "#{HTTP::Write.stream_path stream}/#{stream_version + 1}" location = URI::HTTP.build :path => path batch.events.each do |event| write_records << Record.new(event, stream, expected_version) end location end
write_records()
click to toggle source
# File lib/event_store/http/write/substitute.rb, line 35 def write_records @write_records ||= [] end
written?(&block)
click to toggle source
# File lib/event_store/http/write/substitute.rb, line 39 def written?(&block) block ||= proc { true } write_records.any? do |record| block.(*record.to_a) end end