Class: YSM::Client
- Inherits:
-
Object
- Object
- YSM::Client
- Defined in:
- lib/ysm4r/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#drivers ⇒ Object
readonly
Returns the value of attribute drivers.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(version = nil, options = {}) ⇒ Client
constructor
A new instance of Client.
- #method_missing(m, *args) ⇒ Object
Constructor Details
#initialize(version = nil, options = {}) ⇒ Client
Returns a new instance of Client.
50 51 52 53 54 55 |
# File 'lib/ysm4r/client.rb', line 50 def initialize(version=nil, ={}) @config = Config.new() @headers = @config.makeHeaders @version = (version || Service.getVersions.sort.last) prepareDrivers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ysm4r/client.rb', line 57 def method_missing(m, *args) methodName = m.id2name requestName = YSM::fix_case_up(methodName) # upper first character if driver = @methodMap[methodName] servicename = driver.class.name.split("::").last #args.map! {|a| a.to_s} req = eval("YSM::#{servicename}::#{requestName}").new(*args) return driver.method(methodName).call(req).out else raise(SOAP::MultiService::UnknownAPICall, "Unknown API Call: #{requestName}", caller) end # Handle YSM 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
#config ⇒ Object (readonly)
Returns the value of attribute config.
47 48 49 |
# File 'lib/ysm4r/client.rb', line 47 def config @config end |
#drivers ⇒ Object (readonly)
Returns the value of attribute drivers.
47 48 49 |
# File 'lib/ysm4r/client.rb', line 47 def drivers @drivers end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
47 48 49 |
# File 'lib/ysm4r/client.rb', line 47 def version @version end |