Class: MessagePack::RPCOverHTTP::Server::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/msgpack/rpc_over_http/server/dispatcher.rb

Overview

Dispatcher of user-defined handler.

Instance Method Summary collapse

Constructor Details

#initialize(handler, accept = handler.public_methods) ⇒ Dispatcher



7
8
9
10
# File 'lib/msgpack/rpc_over_http/server/dispatcher.rb', line 7

def initialize(handler, accept=handler.public_methods)
  @handler = handler
  @accept = accept
end

Instance Method Details

#call(env) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/msgpack/rpc_over_http/server/dispatcher.rb', line 12

def call(env)
  method = env['msgpack-rpc.method']
  params = env['msgpack-rpc.params']
  unless @accept.include?(method)
    raise NoMethodError, "method `#{method}' is not accepted"
  end

  return @handler.__send__(method, *params)
end