Class: SOAP::MultiService::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/soapex/client.rb

Defined Under Namespace

Classes: Config

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



39
40
41
42
# File 'lib/soapex/client.rb', line 39

def initialize(options={})
  @methodMap = Hash.new
  prepareDrivers
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/soapex/client.rb', line 44

def method_missing(m, *args)
  methodName = m.id2name
  requestName = fix_case_up(methodName) # upper first character

  if driver = getMethodDriver(methodName)
    serviceName = driver.class.name.split("::").last
    req = getRequestClass(serviceName, requestName).new(*args)
    return driver.method(methodName).call(req)
  else
    raise(SOAP::MultiService::UnknownAPICall,
      "Unknown API Call: #{requestName}", caller)
  end

  # Handle application level error
  rescue SOAP::FaultError => fault
    raise(SOAP::MultiService::ApiError.new(fault),
      "#{methodName} Call Failed: #{fault.faultstring.to_s}", caller)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



37
38
39
# File 'lib/soapex/client.rb', line 37

def config
  @config
end

#driversObject (readonly)

Returns the value of attribute drivers.



37
38
39
# File 'lib/soapex/client.rb', line 37

def drivers
  @drivers
end