Class: Gandi::ProxyCall

Inherits:
Object
  • Object
show all
Defined in:
lib/gandi/session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, api_key) ⇒ ProxyCall

Returns a new instance of ProxyCall.


273
274
275
276
277
278
# File 'lib/gandi/session.rb', line 273

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


282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/gandi/session.rb', line 282

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_keyObject

Returns the value of attribute api_key


271
272
273
# File 'lib/gandi/session.rb', line 271

def api_key
  @api_key
end

#chainedObject

Returns the value of attribute chained


271
272
273
# File 'lib/gandi/session.rb', line 271

def chained
  @chained
end

#serverObject

Returns the value of attribute server


271
272
273
# File 'lib/gandi/session.rb', line 271

def server
  @server
end