# File lib/chef/resource_definition.rb, line 37 def define(resource_name, prototype_params=nil, &block) unless resource_name.kind_of?(Symbol) raise ArgumentError, "You must use a symbol when defining a new resource!" end @name = resource_name if prototype_params unless prototype_params.kind_of?(Hash) raise ArgumentError, "You must pass a hash as the prototype parameters for a definition." end @params = prototype_params end if Kernel.block_given? @recipe = block else raise ArgumentError, "You must pass a block to a definition." end true end
When we do the resource definition, we're really just setting new values for the paramaters we prototyped at the top. This method missing is as simple as it gets.
# File lib/chef/resource_definition.rb, line 59 def method_missing(symbol, *args) @params[symbol] = args.length == 1 ? args[0] : args end
Generated with the Darkfish Rdoc Generator 2.