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

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

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

Instance Attribute Details

- (Object) context (readonly) Originally defined in class Object

An arbitrary context associated with the object.

Returns:

- (void) error

Returns the value of attribute error



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

def error
  @error
end

- (void) id

Returns the value of attribute id



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

def id
  @id
end

- (void) result

Returns the value of attribute result



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

def result
  @result
end

- (void) version

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

- (Hash) to_hash

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