Sha256: 5529ce18a120862ff1bfde3713ae7787a91a51e680f3eed63b3c0495bed5b8f3

Contents?: true

Size: 516 Bytes

Versions: 5

Compression:

Stored size: 516 Bytes

Contents

require "forwardable"

module SandthornSequelProjection
  class EventHandlerCollection
    extend Forwardable
    def_delegators :handlers, :length, :each, :first

    attr_reader :handlers

    def initialize
      @handlers = Set.new
    end

    def define(handler_data)
      @handlers << EventHandler.new(handler_data)
    end

    def handle(projection, events)
      events.each do |event|
        handlers.each do |handler|
          handler.handle(projection, event)
        end
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sandthorn_sequel_projection-0.1.0 lib/sandthorn_sequel_projection/event_handler_collection.rb
sandthorn_sequel_projection-0.0.4 lib/sandthorn_sequel_projection/event_handler_collection.rb
sandthorn_sequel_projection-0.0.3 lib/sandthorn_sequel_projection/event_handler_collection.rb
sandthorn_sequel_projection-0.0.2 lib/sandthorn_sequel_projection/event_handler_collection.rb
sandthorn_sequel_projection-0.0.1 lib/sandthorn_sequel_projection/event_handler_collection.rb