summaryrefslogtreecommitdiff
path: root/lib/chef/platform/resource_priority_map.rb
blob: e98fc12413b8df2663f6093c1847b1f334760e93 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
require 'singleton'

class Chef
  class Platform
    class ResourcePriorityMap
      include Singleton

      def get_priority_array(node, resource_name)
        priority_map.get(node, resource_name.to_sym)
      end

      def set_priority_array(resource_name, priority_array, *filter, &block)
        priority_map.set(resource_name.to_sym, Array(priority_array), *filter, &block)
      end

      # @api private
      def list_handlers(*args)
        priority_map.list(*args).flatten(1).uniq
      end

      private

      def priority_map
        require 'chef/node_map'
        @priority_map ||= Chef::NodeMap.new
      end
    end
  end
end