class Protobuf::Rpc::ServiceDispatcher

Attributes

env[R]

Public Class Methods

new(_app) click to toggle source
# File lib/protobuf/rpc/service_dispatcher.rb, line 10
def initialize(_app)
  # End of the line...
end

Public Instance Methods

call(env) click to toggle source
# File lib/protobuf/rpc/service_dispatcher.rb, line 14
def call(env)
  @env = env

  env.response = dispatch_rpc_request
  env
end
rpc_service() click to toggle source
# File lib/protobuf/rpc/service_dispatcher.rb, line 21
def rpc_service
  @rpc_service ||= env.rpc_service.new(env)
end

Private Instance Methods

dispatch_rpc_request() click to toggle source

Call the given service method.

# File lib/protobuf/rpc/service_dispatcher.rb, line 28
def dispatch_rpc_request
  unless rpc_service.respond_to?(method_name)
    fail MethodNotFound, "#{service_name}##{method_name} is not a publicly defined method."
  end

  rpc_service.callable_rpc_method(method_name).call
  rpc_service.response
end
method_name() click to toggle source
# File lib/protobuf/rpc/service_dispatcher.rb, line 37
def method_name
  env.method_name
end
service_name() click to toggle source
# File lib/protobuf/rpc/service_dispatcher.rb, line 41
def service_name
  env.service_name
end