Class: Gandi::ProxyCall
- Inherits:
-
Object
- Object
- Gandi::ProxyCall
- Defined in:
- lib/gandi/session.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#chained ⇒ Object
Returns the value of attribute chained.
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(server, api_key) ⇒ ProxyCall
constructor
A new instance of ProxyCall.
- #method_missing(method, *args) ⇒ Object
Constructor Details
#initialize(server, api_key) ⇒ ProxyCall
Returns a new instance of ProxyCall.
171 172 173 174 175 176 |
# File 'lib/gandi/session.rb', line 171 def initialize(server, api_key) self.server = server self.api_key = api_key self.chained = [] self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/gandi/session.rb', line 180 def method_missing(method, *args) self.chained << method method_name = chained.join(".") if Gandi::VALID_METHODS.include?(method_name) begin res = self.server.call(method_name, api_key, *args) rescue XMLRPC::FaultException => e raise Gandi::FaultCode.parse(e.faultCode, e.faultString).exception end if res.is_a?(Array) res.collect! { |x| x.is_a?(Hash) ? Hashie::Mash.new(x) : x } elsif res.is_a?(Hash) Hashie::Mash.new(res) else res end else self end end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
169 170 171 |
# File 'lib/gandi/session.rb', line 169 def api_key @api_key end |
#chained ⇒ Object
Returns the value of attribute chained.
169 170 171 |
# File 'lib/gandi/session.rb', line 169 def chained @chained end |
#server ⇒ Object
Returns the value of attribute server.
169 170 171 |
# File 'lib/gandi/session.rb', line 169 def server @server end |