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.
52 53 54 |
# File 'lib/json-rpc-objects/v10/request.rb', line 52 def id @id end |
#method ⇒ Symbol
Holds request method name.
36 37 38 |
# File 'lib/json-rpc-objects/v10/request.rb', line 36 def method @method end |
#params ⇒ Array
Holds params for requested method.
44 45 46 |
# File 'lib/json-rpc-objects/v10/request.rb', line 44 def params @params end |
Class Method Details
.create(method, params = [ ], opts = { }) ⇒ V10::Request
Creates new one.
64 65 66 67 68 69 70 71 72 |
# File 'lib/json-rpc-objects/v10/request.rb', line 64 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.
78 79 80 81 82 |
# File 'lib/json-rpc-objects/v10/request.rb', line 78 def check! self.normalize! __check_method __check_params end |
#notification? ⇒ Boolean
Indicates, it’s notification.
103 104 105 |
# File 'lib/json-rpc-objects/v10/request.rb', line 103 def notification? @id.nil? end |
#output ⇒ Hash
Renders data to output hash.
89 90 91 92 93 94 95 96 |
# File 'lib/json-rpc-objects/v10/request.rb', line 89 def output self.check! data = { "method" => @method.to_s, "params" => @params, "id" => @id } end |