Method: Inspec::ResourceDSL#method_missing
- Defined in:
- lib/inspec/plugin/v1/plugin_types/resource.rb
#method_missing(method_name, *arguments, &block) ⇒ Object
Support for Resource DSL plugins. This is called when an unknown method is encountered within a resource class definition. Even tho this is defined as an instance method, it gets added to Inspec::Plugins::Resource via ‘extend`, so this is actually a class defintion.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/inspec/plugin/v1/plugin_types/resource.rb', line 51 def method_missing(method_name, *arguments, &block) require "inspec/plugin/v2" # Check to see if there is a resource_dsl plugin activator hook with the method name registry = Inspec::Plugin::V2::Registry.instance hook = registry.find_activators(plugin_type: :resource_dsl, activator_name: method_name).first if hook # OK, load the hook if it hasn't been already. We'll then know a module, # which we can then inject into the resource hook.activate # Inject the module's methods into the resource as class methods. # implementation_class is the field name, but this is actually a module. extend(hook.implementation_class) # Now that the module is loaded, it defined one or more methods # (presumably the one we were looking for.) # We still haven't called it, so do so now. send(method_name, *arguments, &block) else # If we couldn't find a plugin to match, maybe something up above has it, # or maybe it is just a unknown method error. super end end |