Class: RubyEventStore::RSpec::FetchEvents

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_event_store/rspec/fetch_events.rb

Constant Summary collapse

MissingEventStore =
Class.new(StandardError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#event_storeObject (readonly)

Returns the value of attribute event_store.


30
31
32
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 30

def event_store
  @event_store
end

#startObject (readonly)

Returns the value of attribute start.


30
31
32
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 30

def start
  @start
end

#stream_nameObject (readonly)

Returns the value of attribute stream_name.


30
31
32
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 30

def stream_name
  @stream_name
end

Instance Method Details

#callObject

Raises:


22
23
24
25
26
27
28
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 22

def call
  raise MissingEventStore if event_store.nil?
  events = event_store.read
  events = events.stream(stream_name) if stream_name
  events = events.from(start) if start
  events
end

#from(event_id) ⇒ Object


6
7
8
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 6

def from(event_id)
  @start = event_id
end

#from_lastObject


18
19
20
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 18

def from_last
  @start = call.last&.event_id
end

#in(event_store) ⇒ Object


14
15
16
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 14

def in(event_store)
  @event_store = event_store
end

#stream(stream_name) ⇒ Object


10
11
12
# File 'lib/ruby_event_store/rspec/fetch_events.rb', line 10

def stream(stream_name)
  @stream_name = stream_name
end