Class: Barrister::RpcResponse
- Inherits:
-
Object
- Object
- Barrister::RpcResponse
- Defined in:
- lib/barrister.rb
Overview
Represents as single JSON-RPC response. This is used by the Batch class so that responses are wrapped in a more friendly class container.
Non-batch calls don’t need this wrapper, as they receive the result directly, or have a RpcException raised.
Instance Attribute Summary collapse
-
#error ⇒ Object
Properties exposed on the response.
-
#id ⇒ Object
Properties exposed on the response.
-
#method ⇒ Object
Properties exposed on the response.
-
#params ⇒ Object
Properties exposed on the response.
-
#result ⇒ Object
Properties exposed on the response.
Instance Method Summary collapse
-
#initialize(req, resp) ⇒ RpcResponse
constructor
A new instance of RpcResponse.
Constructor Details
#initialize(req, resp) ⇒ RpcResponse
Returns a new instance of RpcResponse.
424 425 426 427 428 429 430 431 432 433 434 |
# File 'lib/barrister.rb', line 424 def initialize(req, resp) @id = resp["id"] @result = resp["result"] @method = req["method"] @params = req["params"] if resp["error"] e = resp["error"] @error = RpcException.new(e["code"], e["message"], e["data"]) end end |
Instance Attribute Details
#error ⇒ Object
Properties exposed on the response
You can raise ‘resp.error` when you iterate through results from a batch send.
422 423 424 |
# File 'lib/barrister.rb', line 422 def error @error end |
#id ⇒ Object
Properties exposed on the response
You can raise ‘resp.error` when you iterate through results from a batch send.
422 423 424 |
# File 'lib/barrister.rb', line 422 def id @id end |
#method ⇒ Object
Properties exposed on the response
You can raise ‘resp.error` when you iterate through results from a batch send.
422 423 424 |
# File 'lib/barrister.rb', line 422 def method @method end |
#params ⇒ Object
Properties exposed on the response
You can raise ‘resp.error` when you iterate through results from a batch send.
422 423 424 |
# File 'lib/barrister.rb', line 422 def params @params end |
#result ⇒ Object
Properties exposed on the response
You can raise ‘resp.error` when you iterate through results from a batch send.
422 423 424 |
# File 'lib/barrister.rb', line 422 def result @result end |