Class: SandthornSequelProjection::EventHandlerCollection
- Inherits:
-
Object
- Object
- SandthornSequelProjection::EventHandlerCollection
- Extended by:
- Forwardable
- Defined in:
- lib/sandthorn_sequel_projection/event_handler_collection.rb
Instance Attribute Summary collapse
-
#handlers ⇒ Object
readonly
Returns the value of attribute handlers.
Instance Method Summary collapse
- #define(handler_data) ⇒ Object
- #handle(projection, events) ⇒ Object
-
#initialize ⇒ EventHandlerCollection
constructor
A new instance of EventHandlerCollection.
Constructor Details
#initialize ⇒ EventHandlerCollection
Returns a new instance of EventHandlerCollection.
10 11 12 |
# File 'lib/sandthorn_sequel_projection/event_handler_collection.rb', line 10 def initialize @handlers = Set.new end |
Instance Attribute Details
#handlers ⇒ Object (readonly)
Returns the value of attribute handlers.
8 9 10 |
# File 'lib/sandthorn_sequel_projection/event_handler_collection.rb', line 8 def handlers @handlers end |
Instance Method Details
#define(handler_data) ⇒ Object
14 15 16 |
# File 'lib/sandthorn_sequel_projection/event_handler_collection.rb', line 14 def define(handler_data) @handlers << EventHandler.new(handler_data) end |
#handle(projection, events) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/sandthorn_sequel_projection/event_handler_collection.rb', line 18 def handle(projection, events) events.each do |event| handlers.each do |handler| handler.handle(projection, event) end end end |