module CitrusRpc::RpcServer::Dispatcher

Dispatcher

Public Instance Methods

dispatch(msg, services, &block) click to toggle source

Dispatch message to appropriate service object

@param [Hash] msg @param [Hash] services

# File lib/citrus-rpc/rpc-server/dispatcher.rb, line 18
def dispatch msg, services, &block
  unless namespace = services[msg['namespace']]
    block.call Exception.new 'no such namespace: ' + msg['namespace']
    return
  end
  unless service = namespace[msg['service']]
    block.call Exception.new 'no such service: ' + msg['service']
    return
  end
  unless service.respond_to? msg['method']
    block.call Exception.new 'no such method: ' + msg['method']
    return
  end

  service.send msg['method'], *msg['args'], &block
end