Class: Chef::ProviderResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/provider_resolver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#actionObject (readonly)

Returns the value of attribute action.



27
28
29
# File 'lib/chef/provider_resolver.rb', line 27

def action
  @action
end

#nodeObject (readonly)

Returns the value of attribute node.



25
26
27
# File 'lib/chef/provider_resolver.rb', line 25

def node
  @node
end

#resourceObject (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_handlersObject

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

#providersObject

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

#resolveObject



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_handlersObject

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