Class: RPC::Encoders::Json::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/rpc/lib/rpc/encoders/json.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method, params, id = self.generate_id) ⇒ Request

Returns a new instance of Request.



39
40
41
42
# File 'lib/rpc/lib/rpc/encoders/json.rb', line 39

def initialize(method, params, id = self.generate_id)
  @data = {jsonrpc: JSON_RPC_VERSION, method: method, params: params}
  @data.merge!(id: id) unless id.nil?
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



38
39
40
# File 'lib/rpc/lib/rpc/encoders/json.rb', line 38

def data
  @data
end

Instance Method Details

#generate_idObject



44
45
46
# File 'lib/rpc/lib/rpc/encoders/json.rb', line 44

def generate_id
  rand(999_999_999_999)
end