class Sinatra::RPC::Handler::Introspection

The instrospection handler can be used to display metadata about the RPC server. It adds the ‘listMethods`, `methodSignature` and `methodHelp` RPC methods to the `system` namespace.

Public Class Methods

new(app) click to toggle source

The initializer requires a reference the current application.

@param app [Sinatra::Base] the current Sinatra application

# File lib/sinatra/rpc/handler/introspection.rb, line 12
def initialize(app)
  @app = app
end

Public Instance Methods

list_methods() click to toggle source

List the available methods. @return [Array] the array of methods exposed by this RPC server.

# File lib/sinatra/rpc/handler/introspection.rb, line 18
def list_methods
  index.keys.sort
end
method_help(method_name) click to toggle source

Return a help for the given method. @param method_name [String] the method name in the form ‘handler.methodName`. @return [String] a description of the method.

# File lib/sinatra/rpc/handler/introspection.rb, line 32
def method_help(method_name)
  index[method_name][:help]
end
method_signature(method_name) click to toggle source

Return the signature of the given method. @param method_name [String] the method name in the form ‘handler.methodName`. @return [Array] a list of the form [return, param1, param2, …].

# File lib/sinatra/rpc/handler/introspection.rb, line 25
def method_signature(method_name)
  index[method_name][:signature]
end

Private Instance Methods

index() click to toggle source
# File lib/sinatra/rpc/handler/introspection.rb, line 38
def index
  @app.settings.rpc_method_index
end