Class: MessagePack::RPC::ObjectDispatcher
- Inherits:
-
Object
- Object
- MessagePack::RPC::ObjectDispatcher
- Includes:
- Dispatcher
- Defined in:
- lib/msgpack/rpc/dispatcher.rb
Instance Method Summary collapse
- #dispatch(method, param, &block) ⇒ Object
-
#initialize(obj, accept = obj.public_methods) ⇒ ObjectDispatcher
constructor
A new instance of ObjectDispatcher.
Constructor Details
#initialize(obj, accept = obj.public_methods) ⇒ ObjectDispatcher
Returns a new instance of ObjectDispatcher.
29 30 31 32 |
# File 'lib/msgpack/rpc/dispatcher.rb', line 29 def initialize(obj, accept = obj.public_methods) @obj = obj @accept = accept.map {|m| m.is_a?(Integer) ? m : m.to_s } end |
Instance Method Details
#dispatch(method, param, &block) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/msgpack/rpc/dispatcher.rb', line 34 def dispatch(method, param, &block) unless @accept.include?(method) raise NoMethodError, "method `#{method}' is not accepted" end @obj.send(method, *param, &block) end |