Class: JsonRpcObjects::V10::Request
- Inherits:
-
Generic::Request
- Object
- Generic::Object
- Generic::Request
- JsonRpcObjects::V10::Request
- Defined in:
- lib/json-rpc-objects/v10/request.rb
Overview
Request object class.
Direct Known Subclasses
Constant Summary collapse
- VERSION =
Holds link to its version module.
JsonRpcObjects::V10
Instance Attribute Summary collapse
-
#id ⇒ Object
Call (client) ID.
-
#method ⇒ Symbol
Holds request method name.
-
#params ⇒ Array
Holds params for requested method.
Attributes inherited from Generic::Object
Class Method Summary collapse
-
.create(method, params = [ ], opts = { }) ⇒ V10::Request
Creates new one.
Instance Method Summary collapse
-
#check! ⇒ Object
Checks correctness of the request data.
-
#notification? ⇒ Boolean
Indicates, it’s notification.
-
#output ⇒ Hash
Renders data to output hash.
Methods inherited from Generic::Object
#initialize, parse, #serialize, #to_json, version
Constructor Details
This class inherits a constructor from JsonRpcObjects::Generic::Object
Instance Attribute Details
#id ⇒ Object
Call (client) ID.
53 54 55 |
# File 'lib/json-rpc-objects/v10/request.rb', line 53 def id @id end |
#method ⇒ Symbol
Holds request method name.
37 38 39 |
# File 'lib/json-rpc-objects/v10/request.rb', line 37 def method @method end |
#params ⇒ Array
Holds params for requested method.
45 46 47 |
# File 'lib/json-rpc-objects/v10/request.rb', line 45 def params @params end |
Class Method Details
.create(method, params = [ ], opts = { }) ⇒ V10::Request
Creates new one.
65 66 67 68 69 70 71 72 73 |
# File 'lib/json-rpc-objects/v10/request.rb', line 65 def self.create(method, params = [ ], opts = { }) data = { :method => method, :params => params } data.merge! opts return self::new(data) end |
Instance Method Details
#check! ⇒ Object
Checks correctness of the request data.
79 80 81 82 83 |
# File 'lib/json-rpc-objects/v10/request.rb', line 79 def check! self.normalize! __check_method __check_params end |
#notification? ⇒ Boolean
Indicates, it’s notification.
104 105 106 |
# File 'lib/json-rpc-objects/v10/request.rb', line 104 def notification? @id.nil? end |
#output ⇒ Hash
Renders data to output hash.
90 91 92 93 94 95 96 97 |
# File 'lib/json-rpc-objects/v10/request.rb', line 90 def output self.check! data = { "method" => @method.to_s, "params" => @params, "id" => @id } end |