Class: JsonRpcObjects::V11::WD::ProcedureCall

Inherits:
JsonRpcObjects::V10::Request show all
Includes:
Extensions
Defined in:
lib/json-rpc-objects/v11/wd/procedure-call.rb

Overview

Procedure call (request) class.

Direct Known Subclasses

Request

Constant Summary collapse

VERSION =

Holds link to its version module.

JsonRpcObjects::V11::WD
VERSION_NUMBER =

Holds JSON-RPC version specification.

"1.1"
VERSION_MEMBER =

Holds JSON-RPC version member identification.

"version"

Instance Attribute Summary collapse

Attributes included from Extensions

#extensions

Attributes inherited from JsonRpcObjects::V10::Request

#id, #method, #params

Attributes inherited from Generic::Object

#serializer

Instance Method Summary collapse

Methods included from Extensions

#[], #[]=, #method_missing

Methods inherited from JsonRpcObjects::V10::Request

create, #notification?

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 Attribute Details

#keyword_parametersHash

Holds keyword parameters.

Returns:

  • (Hash)


57
58
59
# File 'lib/json-rpc-objects/v11/wd/procedure-call.rb', line 57

def keyword_parameters
  @keyword_parameters
end

Instance Method Details

#check!Object

Checks correctness of the request data.



64
65
66
67
68
69
70
# File 'lib/json-rpc-objects/v11/wd/procedure-call.rb', line 64

def check!
    super()
    
    if not @keyword_params.nil? and not @keyword_params.kind_of? Hash
        raise Exception::new("Keyword params must be Hash.")
    end
end

#outputHash

Renders data to output hash.

Returns:

  • (Hash)

    with data of call



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/json-rpc-objects/v11/wd/procedure-call.rb', line 78

def output
    self.check!
    
    data = { }

    # Version
    __assign_version(data)
    
    # Method
    data[:method] = @method.to_s
    
    # Params
    __assign_params(data)
    
    # ID
    if not @id.nil?
        data[:id] = @id
    end
    
    data.merge! @extensions                
    return JsonRpcObjects::Utils::Hash.map_keys!(data) { |k| k.to_s }
end