Module: JsonRpcObjects::V11::WD::Extensions

Included in:
Error, ProcedureCall, ProcedureReturn
Defined in:
lib/json-rpc-objects/v11/wd/extensions.rb

Overview

Module for extension support in JSON-RPC 1.1 WD.

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object

Handles method missing call for extensions.

Parameters:

  • name (Symbol)

    of the method, setter if ends with ‘=’

  • value (Object)

    for set

Returns:

  • (Object)

    value set or get



45
46
47
48
49
50
51
# File 'lib/json-rpc-objects/v11/wd/extensions.rb', line 45

def method_missing(name, *args)
    if name.to_s[-1].chr == ?=
        self[name.to_s[0..-2]] = args.first
    else
        self[name]
    end
end

Instance Attribute Details

#extensionsHash

Holds extensions.

Returns:

  • (Hash)


34
35
36
# File 'lib/json-rpc-objects/v11/wd/extensions.rb', line 34

def extensions
  @extensions
end

Instance Method Details

#[](name) ⇒ Object

Handles array access as access for extensions too.

Parameters:

  • name (String)

    of extension for return

Returns:

  • (Object)

    value of extension member



60
61
62
# File 'lib/json-rpc-objects/v11/wd/extensions.rb', line 60

def [](name)
    @extensions[name.to_sym]
end

#[]=(name, value) ⇒ Object

Handles array set to extensions.

@param value of extension for set

Parameters:

  • name (String)

    of extension for set



71
72
73
# File 'lib/json-rpc-objects/v11/wd/extensions.rb', line 71

def []=(name, value)
    @extensions[name.to_sym] = value
end