Class: Nano::Client

Inherits:
Object
  • Object
show all
Includes:
ApplicationHelper
Defined in:
lib/nano_rpc/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host: 'localhost', port: 7076) ⇒ Client

Returns a new instance of Client.



15
16
17
18
# File 'lib/nano_rpc/client.rb', line 15

def initialize(host: 'localhost', port: 7076)
  @host = host
  @port = port
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



13
14
15
# File 'lib/nano_rpc/client.rb', line 13

def host
  @host
end

#portObject

Returns the value of attribute port.



13
14
15
# File 'lib/nano_rpc/client.rb', line 13

def port
  @port
end

Instance Method Details

#call(action, params = {}) ⇒ Object



25
26
27
28
29
30
# File 'lib/nano_rpc/client.rb', line 25

def call(action, params = {})
  args = { action: action }
  args.merge!(params) if params.is_a?(Hash)
  args = extract_proxy_args(args)
  rpc_post(args)
end

#inspectObject

Condense host/port on object inspection



21
22
23
# File 'lib/nano_rpc/client.rb', line 21

def inspect
  "#{inspect_prefix}, @url=\"#{@host}:#{port}\">"
end