Class: Barrister::RpcResponse

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#errorObject

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

#idObject

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

#methodObject

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

#paramsObject

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

#resultObject

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