Method: Jamf::Computer#method_missing
- Defined in:
- lib/jamf/api/classic/api_objects/computer.rb
#method_missing(method, *args, &block) ⇒ Object
Make all the keys of the @hardware hash available as top-level methods on the Computer instance.
This is done by catching method_missing and seeing if the method exists as key of @hardware, and if so, retuning that value, if not, passing on the method_missing call. So:
comp.processor_type
is now the same as:
comp.hardware[:processor_type]
The reason for using ‘method_missing` rather than looping through the speed. When instantiating lots of computers, defining the methods for each one, when those methods may not be needed, just slows things down. This way, they’re only used when needed.
This method may be expanded in the future to handle other ad-hoc, top-level methods.
993 994 995 996 997 998 999 |
# File 'lib/jamf/api/classic/api_objects/computer.rb', line 993 def method_missing(method, *args, &block) if @hardware.key? method @hardware[method] else super end # if end |