Class: QRPC::Protocol::JsonRpc::Request

Inherits:
Abstract::Request show all
Defined in:
lib/qrpc/protocol/json-rpc/request.rb

Overview

JSON-RPC request implementation.

Since:

  • 0.9.0

Instance Attribute Summary collapse

Attributes inherited from Abstract::Object

#options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Abstract::Request

#initialize

Methods inherited from Abstract::Object

#assign_options, #initialize

Constructor Details

This class inherits a constructor from QRPC::Protocol::Abstract::Request

Instance Attribute Details

#nativeJsonRpcObjects::Response

Returns the native object.

Returns:

  • (JsonRpcObjects::Response)

    native response object

Since:

  • 0.9.0



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 62

def native
    if @native.nil?
        client_id = @options.client_id.to_s
        qrpc = QRPC::Protocol::JsonRpc::Native::QrpcObject::create(:client => client_id, :priority => @options.priority, :notification => @options.notification)
        qrpc.serializer = @options.serializer
        
        @native = JsonRpcObjects::Request::create(@options[:method], @options.arguments, :id => @options.id, :qrpc => qrpc.output)
        @native.serializer = @options.serializer
    end
    
    @native
end

Class Method Details

.parse(raw) ⇒ Request

Parses the data for new object.

Parameters:

  • raw (String)

    raw data

Returns:

  • (Request)

    new request according to data

Since:

  • 0.9.0



50
51
52
53
54
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 50

def self.parse(raw)
    object = self::new 
    object.native = JsonRpcObjects::Request::parse(raw, :wd, self::options.serializer)
    return object
end

Instance Method Details

#clientObject

Returns the QRPC request client identifier.

Returns:

Since:

  • 0.9.0



125
126
127
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 125

def client
    @native.qrpc["client"]
end

#idObject

Returns ID of the request.

Returns:

Since:

  • 0.9.0



89
90
91
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 89

def id
    self.native.id
end

#methodSymbol

Returns method identifier of the request.

Returns:

  • (Symbol)

Since:

  • 0.9.0



98
99
100
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 98

def method
    @native.method
end

#notification?Boolean

Indicates, job is notification.

Returns:

  • (Boolean)

Since:

  • 0.9.0



134
135
136
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 134

def notification?
    @native.qrpc["notification"]
end

#paramsArray

Returns method params of the request.

Returns:

  • (Array)

Since:

  • 0.9.0



107
108
109
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 107

def params
    @native.params
end

#priorityInteger

Returns the QRPC request priority.

Returns:

  • (Integer)

Since:

  • 0.9.0



116
117
118
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 116

def priority
    @native.qrpc["priority"]
end

#serializeString

Serializes object to the resultant form.

Returns:

  • (String)

    serialized form

Since:

  • 0.9.0



80
81
82
# File 'lib/qrpc/protocol/json-rpc/request.rb', line 80

def serialize
    self.native.serialize
end