Class: IControl::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/icontrol/base.rb,
lib/icontrol/base/struct.rb,
lib/icontrol/base/mappings.rb,
lib/icontrol/base/sequence.rb,
lib/icontrol/base/exception.rb,
lib/icontrol/base/enumeration.rb,
lib/icontrol/base/attributable.rb

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/icontrol/base.rb', line 208

def method_missing(method_name,*args,&block)

  # When calling an instance method we first check whether there is an argument with
  # that name and return it. If that is not the case we fallback in the class default method but adding the instance as
  # argument (the id), cause thats the way the api works, passing the id
  
  return super if @attributes.has_key? method_name 
  method_name = "get_#{method_name}" if getters.include? method_name

  call_arguments = ( args.first || {} ).merge(default_body)

  return self.class.send(method_name,call_arguments,&block)

end