Class: QRPC::Protocol::JsonRpc::Native::QrpcObject

Inherits:
JsonRpcObjects::Generic::Object
  • Object
show all
Defined in:
lib/qrpc/protocol/json-rpc/native/qrpc-object.rb

Overview

QRPC JSON-RPC QRPC object. Extends the JsonRpcObjects::Generic::Object. See its documentation for additional methods.

Since:

  • 0.2.0

Constant Summary collapse

VERSION =

Holds JSON-RPC version indication.

Since:

  • 0.2.0

JsonRpcObjects::Request::VERSION

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(opts = { }) ⇒ QRPC::Protocol::QrpcObject

Creates new QRPC JSON-RPC object.

Parameters:

  • QRPC (Hash)

    object optional arguments

Returns:

  • (QRPC::Protocol::QrpcObject)

    new instance

Since:

  • 0.2.0



60
61
62
# File 'lib/qrpc/protocol/json-rpc/native/qrpc-object.rb', line 60

def self.create(opts = { })
    self::new(opts)
end

Instance Method Details

#check!Object

Checks correctness of the object data.

Since:

  • 0.2.0



68
69
70
71
72
73
74
75
76
77
78
# File 'lib/qrpc/protocol/json-rpc/native/qrpc-object.rb', line 68

def check!
    self.normalize!
    
    if (not @priority.nil?) and not (@priority.kind_of? Numeric)
        raise Exception::new("Priority is expected to be Numeric.")
    end
    
    if not (@notification.boolean?)
        raise Exception::new("Notification is expected to be Boolean.")
    end
end

#outputHash

Renders data to output form.

Returns:

  • (Hash)

    with data of object

Since:

  • 0.2.0



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/qrpc/protocol/json-rpc/native/qrpc-object.rb', line 85

def output
    result = { 
        "version" => "1.0.2"
    }
    
    if not @priority.nil?
        result["priority"] = @priority
    end
    
    if not @client.nil?
        result["client"] = @client.to_s
    end
    
    if @notification.true?
        result["notification"] = @notification
    end
    
    return result
end