Class: RubyEventStore::SpecificationReader

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

Overview

Used for fetching events based on given query specification.

Instance Method Summary collapse

Constructor Details

#initialize(repository, mapper) ⇒ SpecificationReader

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SpecificationReader.


8
9
10
11
# File 'lib/ruby_event_store/specification_reader.rb', line 8

def initialize(repository, mapper)
  @repository = repository
  @mapper = mapper
end

Instance Method Details

#count(specification_result) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


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

def count(specification_result)
  repository.count(specification_result)
end

#each(specification_result) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


22
23
24
25
26
# File 'lib/ruby_event_store/specification_reader.rb', line 22

def each(specification_result)
  repository.read(specification_result).each do |batch|
    yield batch.map { |record| mapper.record_to_event(record) }
  end
end

#has_event?(event_id) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)

36
37
38
# File 'lib/ruby_event_store/specification_reader.rb', line 36

def has_event?(event_id)
  repository.has_event?(event_id)
end

#one(specification_result) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


15
16
17
18
# File 'lib/ruby_event_store/specification_reader.rb', line 15

def one(specification_result)
  record = repository.read(specification_result)
  mapper.record_to_event(record) if record
end