summaryrefslogtreecommitdiff
path: root/lib/chef/run_context.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/run_context.rb')
-rw-r--r--lib/chef/run_context.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 4f0215bfd4..29edaa262b 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -299,11 +299,57 @@ ERROR_MESSAGE
@reboot_info.size > 0
end
+ #
+ # The list of resource classes for this Chef run.
+ #
+ # @example
+ # ```ruby
+ # run_context.resource_classes.file
+ # #=> Chef::Resource::File
+ # ```
+ #
+ def resource_classes
+ @resource_classes ||= ResourceClasses.new(run_context)
+ end
+
+ #
+ # The list of provider classes for this Chef run.
+ #
+ # @example
+ # ```ruby
+ # run_context.provider_classes.file
+ # #=> Chef::Provider::File
+ # ```
+ #
+ def provider_classes
+ run_context = self
+ @provider_classes ||= Object.new.tap do
+ @run_context = run_context
+ attr_reader :run_context
+ extend Chef::DSL::Providers
+ end
+ end
+
private
def loaded_recipe(cookbook, recipe)
@loaded_recipes["#{cookbook}::#{recipe}"] = true
end
+ class ResourceClasses
+ def initialize(run_context)
+ @run_context = run_context
+ end
+ attr_reader :run_context
+ include Chef::DSL::Resources
+ end
+
+ class ProviderClasses
+ def initialize(run_context)
+ @run_context = run_context
+ end
+ attr_reader :run_context
+ include Chef::DSL::Providers
+ end
end
end