Class: Chef::ProviderResolver
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
-
#enabled_handlers ⇒ Object
this cut looks at if the provider can handle the resource type on the node.
-
#initialize(node, resource, action) ⇒ ProviderResolver
constructor
A new instance of ProviderResolver.
-
#providers ⇒ Object
return a deterministically sorted list of Chef::Provider subclasses.
- #resolve ⇒ Object
-
#supported_handlers ⇒ Object
this cut looks at if the provider can handle the specific resource and action.
Constructor Details
#initialize(node, resource, action) ⇒ ProviderResolver
Returns a new instance of ProviderResolver.
29 30 31 32 33 |
# File 'lib/chef/provider_resolver.rb', line 29 def initialize(node, resource, action) @node = node @resource = resource @action = action end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
27 28 29 |
# File 'lib/chef/provider_resolver.rb', line 27 def action @action end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
25 26 27 |
# File 'lib/chef/provider_resolver.rb', line 25 def node @node end |
#resource ⇒ Object (readonly)
Returns the value of attribute resource.
26 27 28 |
# File 'lib/chef/provider_resolver.rb', line 26 def resource @resource end |
Instance Method Details
#enabled_handlers ⇒ Object
this cut looks at if the provider can handle the resource type on the node
47 48 49 50 51 52 |
# File 'lib/chef/provider_resolver.rb', line 47 def enabled_handlers @enabled_handlers ||= providers.select do |klass| klass.provides?(node, resource) end.sort {|a,b| a.to_s <=> b.to_s } end |
#providers ⇒ Object
return a deterministically sorted list of Chef::Provider subclasses
36 37 38 |
# File 'lib/chef/provider_resolver.rb', line 36 def providers @providers ||= Chef::Provider.descendants end |
#resolve ⇒ Object
40 41 42 43 44 |
# File 'lib/chef/provider_resolver.rb', line 40 def resolve maybe_explicit_provider(resource) || maybe_dynamic_provider_resolution(resource, action) || maybe_chef_platform_lookup(resource) end |
#supported_handlers ⇒ Object
this cut looks at if the provider can handle the specific resource and action
55 56 57 58 59 60 |
# File 'lib/chef/provider_resolver.rb', line 55 def supported_handlers @supported_handlers ||= enabled_handlers.select do |klass| klass.supports?(resource, action) end end |