Class: Rack::RPC::Endpoint::JSONRPC::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/rpc/endpoint/jsonrpc.rb

Overview

JSON-RPC response objects.

Constant Summary

Constants inherited from Object

Object::OPTIONS

Instance Attribute Summary collapse

Attributes inherited from Object

#context

Instance Method Summary collapse

Methods inherited from Object

#initialize, parse, #to_json

Constructor Details

This class inherits a constructor from Rack::RPC::Endpoint::JSONRPC::Object

Instance Attribute Details

#errorObject

Returns the value of attribute error.



198
199
200
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 198

def error
  @error
end

#idObject

Returns the value of attribute id.



199
200
201
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 199

def id
  @id
end

#resultObject

Returns the value of attribute result.



197
198
199
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 197

def result
  @result
end

#versionObject

Returns the value of attribute version.



196
197
198
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 196

def version
  @version
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


203
204
205
206
207
208
209
210
# File 'lib/rack/rpc/endpoint/jsonrpc.rb', line 203

def to_hash
  {
    :jsonrpc => (version || VERSION).to_s,
    :result  => result,
    :error   => error ? error.to_hash : nil,
    :id      => id,
  }
end