Class: Rack::RPC::Endpoint::JSONRPC::Object
- Inherits:
-
Object
- Object
- Rack::RPC::Endpoint::JSONRPC::Object
- Defined in:
- lib/rack/rpc/endpoint/jsonrpc.rb
Overview
Base class for JSON-RPC objects.
Direct Known Subclasses
Constant Summary
- OPTIONS =
{}
Instance Attribute Summary (collapse)
-
- (Object) context
readonly
An arbitrary context associated with the object.
Class Method Summary (collapse)
Instance Method Summary (collapse)
-
- (Object) initialize(options = {}, context = nil)
constructor
A new instance of Object.
- - (String) to_json
Constructor Details
- (Object) initialize(options = {}, context = nil)
Returns a new instance of Object
127 128 129 130 131 132 133 |
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 127 def initialize( = {}, context = nil) = self.class.const_get(:OPTIONS).merge() .each do |k, v| instance_variable_set("@#{k}", v) end @context = context if context end |
Instance Attribute Details
- (Object) context (readonly)
An arbitrary context associated with the object.
121 122 123 |
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 121 def context @context end |
Class Method Details
+ (Object) parse(input)
113 114 115 |
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 113 def self.parse(input) self.new(JSON.parse(input)) end |
Instance Method Details
- (String) to_json
137 138 139 |
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 137 def to_json to_hash.delete_if { |k, v| v.nil? }.to_json end |