Class: Lyra::StateProjection
- Inherits:
-
Projection
- Object
- Projection
- Lyra::StateProjection
- Defined in:
- lib/lyra/projection.rb
Overview
State projection that rebuilds current state from events
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Projection
Class Method Details
Instance Method Details
#rebuild_from_events(events) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/lyra/projection.rb', line 31 def rebuild_from_events(events) state = {} events.each do |event| case event_operation(event) when :created state = event_attributes(event) when :updated state.merge!(event_changes(event).transform_values { |v| v.last }) when :destroyed state[:deleted] = true state[:deleted_at] = (event) end end state end |