Class: HTTPkit::Support::HandlerManager

Inherits:
Object
  • Object
show all
Defined in:
lib/httpkit/support/handler_manager.rb

Defined Under Namespace

Modules: Setup

Instance Method Summary collapse

Constructor Details

#initialize(handlers) ⇒ HandlerManager

Returns a new instance of HandlerManager.



6
7
8
# File 'lib/httpkit/support/handler_manager.rb', line 6

def initialize(handlers)
  @handlers = handlers
end

Instance Method Details

#invoke(message, *arguments) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/httpkit/support/handler_manager.rb', line 10

def invoke(message, *arguments)
  @handlers
    .select { |handler| handler.respond_to?(message) }
    .reduce(arguments) do |args, handler|
      handler.send(message, *args) { |*new_args| args = new_args }
      args
    end
end