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.
170 171 172 173 174 175 |
# File 'lib/gandi/session.rb', line 170 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
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/gandi/session.rb', line 177 def method_missing(method, *args) self.chained << method method_name = chained.join(".") if Gandi::VALID_METHODS.include?(method_name) # puts "CALL: #{method_name} - #{api_key} - #{args.inspect}" method_name.sub!('clone_zone','clone') method_name.sub!('new_version','new') res = self.server.call(method_name, api_key, *args) 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.
168 169 170 |
# File 'lib/gandi/session.rb', line 168 def api_key @api_key end |
#chained ⇒ Object
Returns the value of attribute chained.
168 169 170 |
# File 'lib/gandi/session.rb', line 168 def chained @chained end |
#server ⇒ Object
Returns the value of attribute server.
168 169 170 |
# File 'lib/gandi/session.rb', line 168 def server @server end |