module RJR::HandlesMethods

Mixin adding methods allowing developer to specify JSON-RPC methods which to dispatch to.

@example Defining a structured JSON-RPC method handler

class MyMethodHandler
  include RJR::HandlesMethods

  jr_method :do_something

  def handle(*params)
    'return value'
  end
end

node = RJR::Nodes::TCP.new :host => '0.0.0.0', :port => 8888
MyMethodHandler.dispatch_to(node.dispatcher)
node.listen.join

# clients can now invoke the 'do_something' json-rpc method by
# issuing requests to the target host / port

Public Class Methods

included(base) click to toggle source
# File lib/rjr/util/handles_methods.rb, line 30
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

handle() click to toggle source

Override w/ custom handler logic

# File lib/rjr/util/handles_methods.rb, line 35
def handle
end