Class: Chef::ResourceResolver
- Inherits:
-
Object
- Object
- Chef::ResourceResolver
- Includes:
- Mixin::ConvertToClassName
- Defined in:
- lib/chef/resource_resolver.rb
Instance Attribute Summary collapse
- #action ⇒ Object readonly private
- #node ⇒ Object readonly private
- #resource_name ⇒ Object readonly private
Class Method Summary collapse
-
.includes_handler?(resource_name, resource_class) ⇒ Boolean
private
Whether the given handler attempts to provide the resource class at all.
-
.list(resource_name, node: nil) ⇒ Object
Resolve a list of all resources that implement the given DSL (in order of preference).
-
.resolve(resource_name, node: nil) ⇒ Object
Resolve a resource by name.
Instance Method Summary collapse
-
#initialize(node, resource_name) ⇒ ResourceResolver
constructor
Create a resolver.
- #list ⇒ Object private
-
#provided_by?(resource_class) ⇒ Boolean
private
Whether this DSL is provided by the given resource_class.
- #resolve ⇒ Object
Methods included from Mixin::ConvertToClassName
#convert_to_class_name, #convert_to_snake_case, #filename_to_qualified_string, #normalize_snake_case_name, #snake_case_basename
Constructor Details
#initialize(node, resource_name) ⇒ ResourceResolver
Create a resolver.
65 66 67 68 |
# File 'lib/chef/resource_resolver.rb', line 65 def initialize(node, resource_name) @node = node @resource_name = resource_name.to_sym end |
Instance Attribute Details
#action ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/chef/resource_resolver.rb', line 55 def action @action end |
#node ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
51 52 53 |
# File 'lib/chef/resource_resolver.rb', line 51 def node @node end |
#resource_name ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
53 54 55 |
# File 'lib/chef/resource_resolver.rb', line 53 def resource_name @resource_name end |
Class Method Details
.includes_handler?(resource_name, resource_class) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether the given handler attempts to provide the resource class at all.
107 108 109 |
# File 'lib/chef/resource_resolver.rb', line 107 def self.includes_handler?(resource_name, resource_class) handler_map.list(nil, resource_name).include?(resource_class) end |
.list(resource_name, node: nil) ⇒ Object
Resolve a list of all resources that implement the given DSL (in order of preference).
44 45 46 |
# File 'lib/chef/resource_resolver.rb', line 44 def self.list(resource_name, node: nil) new(node, resource_name).list end |
.resolve(resource_name, node: nil) ⇒ Object
Resolve a resource by name.
32 33 34 |
# File 'lib/chef/resource_resolver.rb', line 32 def self.resolve(resource_name, node: nil) new(node, resource_name).resolve end |
Instance Method Details
#list ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 90 |
# File 'lib/chef/resource_resolver.rb', line 87 def list Chef::Log.trace "Resources for generic #{resource_name} resource enabled on node include: #{prioritized_handlers}" prioritized_handlers end |
#provided_by?(resource_class) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether this DSL is provided by the given resource_class.
Does NOT call provides? on the resource (it is assumed this is being called from provides?).
99 100 101 |
# File 'lib/chef/resource_resolver.rb', line 99 def provided_by?(resource_class) potential_handlers.include?(resource_class) end |
#resolve ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/chef/resource_resolver.rb', line 71 def resolve # log this so we know what resources will work for the generic resource on the node (early cut) Chef::Log.trace "Resources for generic #{resource_name} resource enabled on node include: #{prioritized_handlers}" handler = prioritized_handlers.first if handler Chef::Log.trace "Resource for #{resource_name} is #{handler}" else Chef::Log.trace "Dynamic resource resolver FAILED to resolve a resource for #{resource_name}" end handler end |