class Protobuf::Rpc::Client
def method_missing(method_name, *params)
end
c.on_failure {|err| ... }
c.on_success {|res| ... }
# `c` in this case is the client object you created above
# This block will be invoked before the request is made
Client.new(:service => WidgetService).find do |c|
# The :find method is not defined by Client which will trigger method_missing
in the wrapper protobuf request.
which will automatically setup the service_class and method_name
Provides a mechanism to call the service method against the client
def method_missing(method_name, *params) service = options[:service] unless service.rpc_method?(method_name) log_error { sign_message("#{service.name}##{method_name.to_s} not rpc method, passing to super") } super(method_name, *params) else log_debug { sign_message("#{service.name}##{method_name.to_s}") } rpc = service.rpcs[method_name.to_sym] options[:request_type] = rpc.request_type log_debug { sign_message("Request Type: #{options[:request_type].name}") } options[:response_type] = rpc.response_type log_debug { sign_message("Response Type: #{options[:response_type].name}") } options[:method] = method_name.to_s options[:request] = params[0].is_a?(Hash) ? options[:request_type].new(params[0]) : params[0] log_debug { sign_message("Request Data: #{options[:request].inspect}") } # Call client to setup on_success and on_failure event callbacks if block_given? log_debug { sign_message("client setup callback given, invoking") } yield(self) else log_debug { sign_message("no block given for callbacks") } end send_request end end