diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-06 07:59:33 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-02 09:53:39 -0700 |
commit | 9028823f7b046c4c081b1cb1df005d61fbfa1db2 (patch) | |
tree | 74d1fa52adb202a6841148be3b82638a578b1b4e /lib/chef/mixin | |
parent | 93f7b74349362d0c698a1080177b94e64248dac6 (diff) | |
download | chef-9028823f7b046c4c081b1cb1df005d61fbfa1db2.tar.gz |
Use the central priority map for `provides`
Diffstat (limited to 'lib/chef/mixin')
-rw-r--r-- | lib/chef/mixin/provides.rb | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/lib/chef/mixin/provides.rb b/lib/chef/mixin/provides.rb index c39c53a190..c95cb753a8 100644 --- a/lib/chef/mixin/provides.rb +++ b/lib/chef/mixin/provides.rb @@ -4,30 +4,21 @@ require 'chef/mixin/descendants_tracker' class Chef module Mixin module Provides + # TODO no longer needed, remove or deprecate? include Chef::Mixin::DescendantsTracker - def node_map - @node_map ||= Chef::NodeMap.new - end - def provides(short_name, opts={}, &block) - if !short_name.kind_of?(Symbol) - # YAGNI: this is probably completely unnecessary and can be removed? - Chef::Log.deprecation "Passing a non-Symbol to Chef::Resource#provides will be removed" - if short_name.kind_of?(String) - short_name.downcase! - short_name.gsub!(/\s/, "_") - end - short_name = short_name.to_sym - end - node_map.set(short_name, true, opts, &block) + provides_priority_map.priority(short_name, self, opts, &block) end # Check whether this resource provides the resource_name DSL for the given - # node - def provides?(node, resource_name) - resource_name = resource_name.resource_name if resource_name.is_a?(Chef::Resource) - node_map.get(node, resource_name) + # node. + def provides?(node, short_name) + provides_priority_map.list(node, short_name).include?(self) + end + + def provides_priority_map + raise NotImplementedError, :provides_priority_map end # Get the list of recipe DSL this resource is responsible for on the given |