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.



28
29
30
# File 'lib/ruby_event_store/specification_reader.rb', line 28

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
# File 'lib/ruby_event_store/specification_reader.rb', line 22

def each(specification_result)
  repository.read(specification_result).each { |batch| yield batch.map { |record| mapper.record_to_event(record) } }
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