Class: Exots::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/exots/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socket_path) ⇒ Context

Returns a new instance of Context.



11
12
13
# File 'lib/exots/context.rb', line 11

def initialize(socket_path)
  @socket_path = socket_path
end

Instance Attribute Details

#socket_pathObject (readonly)

Returns the value of attribute socket_path.



9
10
11
# File 'lib/exots/context.rb', line 9

def socket_path
  @socket_path
end

Instance Method Details

#call(method, *args) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/exots/context.rb', line 15

def call(method, *args)
  id = SecureRandom.uuid

  payload = {
    jsonrpc: '2.0',
    method: method,
    params: args,
    id: id
  }

  response = send_request(payload)
  handle_response(response, id)
end