Module: Synapse::EventSourcing::Entity
- Extended by:
- ActiveSupport::Concern
- Includes:
- Member
- Defined in:
- lib/synapse/event_sourcing/entity.rb
Overview
Mixin for an entity that is part of an event-sourced aggregate
Instead managing its own published events, the entity relies on being registered to the aggregate root and using its event container. Events applied to child entities will be cascaded throughout the entire aggregate.
Instance Method Summary collapse
-
#aggregate_root=(aggregate_root) ⇒ undefined
private
Registers this entity to the aggregate root.
-
#handle_aggregate_event(event) ⇒ undefined
private
Handles an aggregate event locally and then cascades to any registered child entities.
Instance Method Details
#aggregate_root=(aggregate_root) ⇒ undefined
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.
Registers this entity to the aggregate root
27 28 29 30 31 32 33 |
# File 'lib/synapse/event_sourcing/entity.rb', line 27 def aggregate_root=(aggregate_root) if @aggregate_root and !@aggregate_root.equal? aggregate_root raise 'Entity is registered to a different aggregate root' end @aggregate_root = aggregate_root end |
#handle_aggregate_event(event) ⇒ undefined
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.
Handles an aggregate event locally and then cascades to any registered child entities
17 18 19 |
# File 'lib/synapse/event_sourcing/entity.rb', line 17 def handle_aggregate_event(event) handle_recursively event end |