Class: RubyEventStore::SpecificationReader
- Inherits:
-
Object
- Object
- RubyEventStore::SpecificationReader
- Defined in:
- lib/ruby_event_store/specification_reader.rb
Overview
Used for fetching events based on given query specification.
Instance Method Summary collapse
- #count(specification_result) ⇒ Object private
- #each(specification_result) ⇒ Object private
- #has_event?(event_id) ⇒ Boolean private
-
#initialize(repository, mapper) ⇒ SpecificationReader
constructor
private
A new instance of SpecificationReader.
- #one(specification_result) ⇒ Object private
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.
6 7 8 9 |
# File 'lib/ruby_event_store/specification_reader.rb', line 6 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.
20 21 22 23 24 |
# File 'lib/ruby_event_store/specification_reader.rb', line 20 def each(specification_result) repository.read(specification_result).each do |batch| yield batch.map { |serialized_record| mapper.serialized_record_to_event(serialized_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.
34 35 36 |
# File 'lib/ruby_event_store/specification_reader.rb', line 34 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.
13 14 15 16 |
# File 'lib/ruby_event_store/specification_reader.rb', line 13 def one(specification_result) record = repository.read(specification_result) mapper.serialized_record_to_event(record) if record end |