Class: Legion::Data::EventStore::Projection
- Inherits:
-
Object
- Object
- Legion::Data::EventStore::Projection
- Defined in:
- lib/legion/data/event_store/projection.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Class Method Summary collapse
Instance Method Summary collapse
- #apply(_event) ⇒ Object
-
#initialize ⇒ Projection
constructor
A new instance of Projection.
Constructor Details
#initialize ⇒ Projection
Returns a new instance of Projection.
9 10 11 |
# File 'lib/legion/data/event_store/projection.rb', line 9 def initialize @state = {} end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
7 8 9 |
# File 'lib/legion/data/event_store/projection.rb', line 7 def state @state end |
Class Method Details
.build_from(stream, since: nil) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/legion/data/event_store/projection.rb', line 17 def self.build_from(stream, since: nil) projection = new events = EventStore.read_stream(stream, since: since) events.each { |e| projection.apply(e) } projection end |
Instance Method Details
#apply(_event) ⇒ Object
13 14 15 |
# File 'lib/legion/data/event_store/projection.rb', line 13 def apply(_event) raise NotImplementedError, "#{self.class} must implement #apply" end |