diff options
author | John Keiser <john@johnkeiser.com> | 2015-06-05 10:48:29 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-08 09:01:54 -0700 |
commit | 8f17f5223727cb9bec3c44b66a3fbe327b7a2f19 (patch) | |
tree | 05cebef51365af906081bc1430c6c15d048a7b40 /lib/chef/chef_class.rb | |
parent | 8d4e9d44995d6f7de5a0b681616ed8241e39ece3 (diff) | |
download | chef-8f17f5223727cb9bec3c44b66a3fbe327b7a2f19.tar.gz |
Make use_automatic_resource_name automatic
Diffstat (limited to 'lib/chef/chef_class.rb')
-rw-r--r-- | lib/chef/chef_class.rb | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb index 7c0a2bf944..1caeee4052 100644 --- a/lib/chef/chef_class.rb +++ b/lib/chef/chef_class.rb @@ -36,50 +36,74 @@ class Chef # Public API # + # # Get the node object # # @return [Chef::Node] node object of the chef-client run + # attr_reader :node + # # Get the run context # # @return [Chef::RunContext] run_context of the chef-client run + # attr_reader :run_context + # # Get the array of providers associated with a resource_name for the current node # # @param resource_name [Symbol] name of the resource as a symbol + # # @return [Array<Class>] Priority Array of Provider Classes to use for the resource_name on the node + # def get_provider_priority_array(resource_name) - provider_priority_map.get_priority_array(node, resource_name).dup + result = provider_priority_map.get_priority_array(node, resource_name) + result = result.dup if result + result end + # # Get the array of resources associated with a resource_name for the current node # # @param resource_name [Symbol] name of the resource as a symbol + # # @return [Array<Class>] Priority Array of Resource Classes to use for the resource_name on the node + # def get_resource_priority_array(resource_name) - resource_priority_map.get_priority_array(node, resource_name).dup + result = resource_priority_map.get_priority_array(node, resource_name) + result = result.dup if result + result end + # # Set the array of providers associated with a resource_name for the current node # # @param resource_name [Symbol] name of the resource as a symbol # @param priority_array [Class, Array<Class>] Class or Array of Classes to set as the priority for resource_name on the node # @param filter [Hash] Chef::Nodearray-style filter + # # @return [Array<Class>] Modified Priority Array of Provider Classes to use for the resource_name on the node + # def set_provider_priority_array(resource_name, priority_array, *filter, &block) - provider_priority_map.set_priority_array(resource_name, priority_array, *filter, &block).dup + result = provider_priority_map.set_priority_array(resource_name, priority_array, *filter, &block) + result = result.dup if result + result end + # # Get the array of resources associated with a resource_name for the current node # # @param resource_name [Symbol] name of the resource as a symbol # @param priority_array [Class, Array<Class>] Class or Array of Classes to set as the priority for resource_name on the node # @param filter [Hash] Chef::Nodearray-style filter + # # @return [Array<Class>] Modified Priority Array of Resource Classes to use for the resource_name on the node + # def set_resource_priority_array(resource_name, priority_array, *filter, &block) - resource_priority_map.set_priority_array(resource_name, priority_array, *filter, &block).dup + result = resource_priority_map.set_priority_array(resource_name, priority_array, *filter, &block) + result = result.dup if result + result end # @@ -88,22 +112,27 @@ class Chef # *NOT* for public consumption ] # + # # Sets the resource_priority_map # - # @api private # @param resource_priority_map [Chef::Platform::ResourcePriorityMap] + # + # @api private def set_resource_priority_map(resource_priority_map) @resource_priority_map = resource_priority_map end + # # Sets the provider_priority_map # - # @api private # @param provider_priority_map [Chef::Platform::providerPriorityMap] + # + # @api private def set_provider_priority_map(provider_priority_map) @provider_priority_map = provider_priority_map end + # # Sets the node object # # @api private @@ -112,14 +141,17 @@ class Chef @node = node end + # # Sets the run_context object # - # @api private # @param run_context [Chef::RunContext] + # + # @api private def set_run_context(run_context) @run_context = run_context end + # # Resets the internal state # # @api private @@ -130,6 +162,14 @@ class Chef @resource_priority_map = nil end + # + # Removes a resource + # + # @api private + def delete_resource_priority_array(name, &filter) + resource_priority_map.delete_priority_array(name, &filter) + end + private def provider_priority_map |