Class: Toaster::ToasterAppClient

Inherits:
XMLRPC::Client
  • Object
show all
Defined in:
lib/toaster/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 8385) ⇒ ToasterAppClient

Returns a new instance of ToasterAppClient.



421
422
423
424
425
426
427
# File 'lib/toaster/api.rb', line 421

def initialize(host, port=8385)
  @host = host.include?(":") ? host.gsub(/([^:]+):.*/, '\1') : host
  @port = host.include?(":") ? host.gsub(/([^:]+):(.+)/, '\2') : port
  @port = @port.to_i
  super(@host, "/", @port)
  self.timeout = 60*60 # timeout of 1h for RPC calls
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



428
429
430
# File 'lib/toaster/api.rb', line 428

def method_missing(name, *args, &block)
  call(name, *args, &block)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



419
420
421
# File 'lib/toaster/api.rb', line 419

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



419
420
421
# File 'lib/toaster/api.rb', line 419

def port
  @port
end

Instance Method Details

#to_sObject



431
432
433
# File 'lib/toaster/api.rb', line 431

def to_s
  "ServiceProxy<#{host}:#{port}>"
end