Class: Burrow::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/burrow/request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#methodObject (readonly)

Returns the value of attribute method.



3
4
5
# File 'lib/burrow/request.rb', line 3

def method
  @method
end

#paramsObject (readonly)

Returns the value of attribute params.



3
4
5
# File 'lib/burrow/request.rb', line 3

def params
  @params
end

Instance Method Details

#attributesObject



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

#idObject



10
11
12
# File 'lib/burrow/request.rb', line 10

def id
  @id ||= SecureRandom.hex
end

#jsonObject



22
23
24
# File 'lib/burrow/request.rb', line 22

def json
  JSON.generate(attributes)
end