Module: RJR::HandlesMethods

Defined in:
lib/rjr/util/handles_methods.rb

Overview

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

Examples:

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

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



30
31
32
# File 'lib/rjr/util/handles_methods.rb', line 30

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#handleObject

Override w/ custom handler logic



35
36
# File 'lib/rjr/util/handles_methods.rb', line 35

def handle
end