Class: JsonRpcObjects::V20::Request

Overview

Request object class.

Constant Summary collapse

VERSION =

Holds link to its version module.

JsonRpcObjects::V20
VERSION_NUMBER =

Holds JSON-RPC version specification.

"2.0"
VERSION_MEMBER =

Holds JSON-RPC version member identification.

"jsonrpc"

Instance Attribute Summary

Attributes inherited from JsonRpcObjects::V11::WD::ProcedureCall

#keyword_parameters

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

#extensions

Attributes inherited from JsonRpcObjects::V10::Request

#id, #method, #params

Attributes inherited from Generic::Object

#serializer

Instance Method Summary collapse

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

#[], #[]=, #method_missing

Methods inherited from JsonRpcObjects::V10::Request

create

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.



54
55
56
57
58
59
60
# File 'lib/json-rpc-objects/v20/request.rb', line 54

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

#notification?Boolean

Indicates, it’s notification.

Returns:

  • (Boolean)

    true if it is, otherwise false



82
83
84
# File 'lib/json-rpc-objects/v20/request.rb', line 82

def notification?
    not @_id_set
end

#outputHash

Renders data to output hash.

Returns:

  • (Hash)

    with data of error



67
68
69
70
71
72
73
74
75
# File 'lib/json-rpc-objects/v20/request.rb', line 67

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

    return result
end