summaryrefslogtreecommitdiff
path: root/lib/chef/platform
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-06-29 16:20:15 -0600
committerJohn Keiser <john@johnkeiser.com>2015-06-30 11:18:41 -0600
commit7f2efa0bdabee2745b9b61725d88944bedd44052 (patch)
tree95dc93c7059d18ac90b173fca227dd284f2131cc /lib/chef/platform
parent2bf7afdba5496f5f3e7ba065650c6db5522fe8c1 (diff)
downloadchef-7f2efa0bdabee2745b9b61725d88944bedd44052.tar.gz
Optimize logic on class initialize so it doesn't fall into the
"look at all classes to see if they provide the DSL" else clause when you're just setting resource_name (which happens on every class). Perf fix for tests.
Diffstat (limited to 'lib/chef/platform')
-rw-r--r--lib/chef/platform/priority_map.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/chef/platform/priority_map.rb b/lib/chef/platform/priority_map.rb
index d559eece78..73554eafe1 100644
--- a/lib/chef/platform/priority_map.rb
+++ b/lib/chef/platform/priority_map.rb
@@ -6,7 +6,7 @@ class Chef
def priority(resource_name, priority_array, *filter)
set_priority_array(resource_name.to_sym, priority_array, *filter)
end
-
+
# @api private
def get_priority_array(node, key)
get(node, key)
@@ -24,6 +24,12 @@ class Chef
list(node, key, **filters).flatten(1).uniq
end
+ # @api private
+ def includes_handler?(key, handler)
+ return false if !map.has_key?(key)
+ map[key].any? { |m| h = m[:value]; h.is_a?(Array) ? h.include?(handler) : h == handler }
+ end
+
#
# Priority maps have one extra precedence: priority arrays override "provides,"
# and "provides" lines with identical filters sort by class name (ascending).