Class: JsonRpcObjects::V20::Response

Overview

Response object class.

Constant Summary collapse

VERSION =

Holds link to its version module.

JsonRpcObjects::V20
ERROR_CLASS =

Identifies the error object class.

JsonRpcObjects::V20::Error
VERSION_NUMBER =

Holds JSON-RPC version specification.

"2.0"
VERSION_MEMBER =

Holds JSON-RPC version member identification.

"jsonrpc"

Instance Attribute Summary

Attributes included from JsonRpcObjects::V11::WD::Extensions

#extensions

Attributes inherited from JsonRpcObjects::V10::Response

#error, #id, #result

Attributes inherited from Generic::Object

#serializer

Instance Method Summary collapse

Methods included from JsonRpcObjects::V11::WD::Extensions

#[], #[]=, #method_missing

Methods inherited from JsonRpcObjects::V10::Response

#<<, create, #error?

Methods inherited from Generic::Object

create, #initialize, parse, #serialize, #to_json, version

Constructor Details

This class inherits a constructor from JsonRpcObjects::Generic::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JsonRpcObjects::V11::WD::Extensions

Instance Method Details

#check!Object

Checks correctness of the request data.



60
61
62
63
64
65
66
# File 'lib/json-rpc-objects/v20/response.rb', line 60

def check!
    super()
    
    if not [Symbol, String, Integer, NilClass].any?{ |cl| @id.kind_of?(cl) }
        raise Exception::new("ID must contain Symbol, String, Number or nil if included.")
    end
end

#outputHash

Renders data to output hash.

Returns:

  • (Hash)

    with data of error



73
74
75
76
77
78
79
80
81
# File 'lib/json-rpc-objects/v20/response.rb', line 73

def output
    result = super()
    
    if @_id_set and @id.nil?
        result["id"] = nil
    end
    
    return result
end