Class: SandthornSequelProjection::EventHandlerCollection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sandthorn_sequel_projection/event_handler_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEventHandlerCollection

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

#handlersObject (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