class Rack::RPC::Endpoint::JSONRPC::Object

Base class for JSON-RPC objects.

Constants

OPTIONS

Attributes

context[R]

An arbitrary context associated with the object.

@return [Object]

Public Class Methods

new(options = {}, context = nil) click to toggle source

@param [Hash] options @param [Object] context

an optional context to associate with the object
# File lib/rack/rpc/endpoint/jsonrpc.rb, line 127
def initialize(options = {}, context = nil)
  options = self.class.const_get(:OPTIONS).merge(options)
  options.each do |k, v|
    instance_variable_set("@#{k}", v)
  end
  @context = context if context
end
parse(input) click to toggle source

@param [String] input @return [Object]

# File lib/rack/rpc/endpoint/jsonrpc.rb, line 113
def self.parse(input)
  self.new(JSON.parse(input))
end

Public Instance Methods

to_json() click to toggle source

@return [String]

# File lib/rack/rpc/endpoint/jsonrpc.rb, line 137
def to_json
  to_hash.delete_if { |k, v| v.nil? }.to_json
end