class XmlRPCBase

Attributes

rpc_cl[R]

Public Class Methods

new(settings={}) click to toggle source

Initializes XMLRPC connection. Needs connection and Request parameters via given settings hash

@param settings hash of settings: :host, :port, :path

# File lib/o3d3xx/xml_rpc_base.rb, line 26
def initialize(settings={})
  raise 'No host name given !' if settings[:host].nil?
  raise 'No port given !' if settings[:port].nil?
  raise 'No endpoint given !' if settings[:path].nil?
  @config = {
    :host => settings[:host],
    :port => settings[:port],
    :path => '/api/rpc/v1/' + settings[:path]
  }

  @rpc_cl = XMLRPC::Client.new(@config[:host],
                               @config[:path],
                               @config[:port], nil, nil,
                               nil, nil, nil, 20)   # 20 seconds connection timeout
  #dump
end

Public Instance Methods

dump() click to toggle source

Dumps configuration

# File lib/o3d3xx/xml_rpc_base.rb, line 66
def dump
  puts "Host: #{@config[:host]}"
  puts "Port: #{@config[:port]}"
  puts "URL : #{@config[:path]}"
end
getConfig() click to toggle source

Returns configuration object

# File lib/o3d3xx/xml_rpc_base.rb, line 60
def getConfig
  return @config
end
method_missing(meth, *args) click to toggle source

Calls any method via xmlrpc

Calls superclass method
# File lib/o3d3xx/xml_rpc_base.rb, line 45
def method_missing(meth, *args)
  arg = args
  begin
    @rpc_cl.call_async(meth.to_s, *arg)
  rescue XMLRPC::FaultException => e
    if e.message.include? 'method not found'
      super
    else
      raise
    end
  end
end