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.
123 124 125 126 127 128 |
# File 'lib/gandi/session.rb', line 123 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
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/gandi/session.rb', line 130 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}" 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.
121 122 123 |
# File 'lib/gandi/session.rb', line 121 def api_key @api_key end |
#chained ⇒ Object
Returns the value of attribute chained.
121 122 123 |
# File 'lib/gandi/session.rb', line 121 def chained @chained end |
#server ⇒ Object
Returns the value of attribute server.
121 122 123 |
# File 'lib/gandi/session.rb', line 121 def server @server end |