Class: Burrow::Request
- Inherits:
-
Object
- Object
- Burrow::Request
- Defined in:
- lib/burrow/request.rb
Instance Attribute Summary collapse
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #attributes ⇒ Object
- #id ⇒ Object
-
#initialize(method, params = {}) ⇒ Request
constructor
A new instance of Request.
- #json ⇒ Object
Constructor Details
#initialize(method, params = {}) ⇒ Request
Returns a new instance of Request.
5 6 7 8 |
# File 'lib/burrow/request.rb', line 5 def initialize(method, params={}) @method = method @params = params end |
Instance Attribute Details
#method ⇒ Object (readonly)
Returns the value of attribute method.
3 4 5 |
# File 'lib/burrow/request.rb', line 3 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
3 4 5 |
# File 'lib/burrow/request.rb', line 3 def params @params end |
Instance Method Details
#attributes ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/burrow/request.rb', line 14 def attributes { jsonrpc: '2.0', id: id, method: method, params: params } end |
#id ⇒ Object
10 11 12 |
# File 'lib/burrow/request.rb', line 10 def id @id ||= SecureRandom.hex end |
#json ⇒ Object
22 23 24 |
# File 'lib/burrow/request.rb', line 22 def json JSON.generate(attributes) end |