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/node_map.rb | |
parent | 93f7b74349362d0c698a1080177b94e64248dac6 (diff) | |
download | chef-9028823f7b046c4c081b1cb1df005d61fbfa1db2.tar.gz |
Use the central priority map for `provides`
Diffstat (limited to 'lib/chef/node_map.rb')
-rw-r--r-- | lib/chef/node_map.rb | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index 2ca6d9ba17..7c25cb841a 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -68,14 +68,16 @@ class Chef def get(node, key) # FIXME: real exception raise "first argument must be a Chef::Node" unless node.is_a?(Chef::Node) - return nil unless @map.has_key?(key) - @map[key].each do |matcher| - if filters_match?(node, matcher[:filters]) && - block_matches?(node, matcher[:block]) - return matcher[:value] - end - end - nil + list(node, key).first + end + + def list(node, key) + # FIXME: real exception + raise "first argument must be a Chef::Node" unless node.is_a?(Chef::Node) + return [] unless @map.has_key?(key) + @map[key].select do |matcher| + filters_match?(node, matcher[:filters]) && block_matches?(node, matcher[:block]) + end.map { |matcher| matcher[:value] } end private |