Class: MmJsonClient::JsonRpcHttp::Response
- Inherits:
-
Object
- Object
- MmJsonClient::JsonRpcHttp::Response
- Defined in:
- lib/mm_json_client/json_rpc_http/response.rb
Overview
A standard formatted JSON-RPC response.
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(json) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(json) ⇒ Response
Returns a new instance of Response.
14 15 16 17 18 19 20 21 22 |
# File 'lib/mm_json_client/json_rpc_http/response.rb', line 14 def initialize(json) data = JSON.parse(json) @version = data['version'] @result = data['result'] @error = data['error'] && new_error(data['error']) @id = data['id'] rescue JSON::ParserError raise InvalidResponseFormat end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
9 10 11 |
# File 'lib/mm_json_client/json_rpc_http/response.rb', line 9 def error @error end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/mm_json_client/json_rpc_http/response.rb', line 10 def id @id end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
11 12 13 |
# File 'lib/mm_json_client/json_rpc_http/response.rb', line 11 def result @result end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
12 13 14 |
# File 'lib/mm_json_client/json_rpc_http/response.rb', line 12 def version @version end |