Class: MmJsonClient::JsonRpcHttp::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/mm_json_client/json_rpc_http/response.rb

Overview

A standard formatted JSON-RPC response.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#errorObject (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

#idObject (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

#resultObject (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

#versionObject (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