summaryrefslogtreecommitdiff
path: root/lib/chef/run_context.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-10-18 10:46:54 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-10-18 10:46:54 -0700
commitdffde98d6228ccb4ea1dbd19d4db08edc62625b8 (patch)
tree39b5e058f3b435256123f437d2c7a8b39de923b4 /lib/chef/run_context.rb
parent770ad9a6f575bf21d73c542756aeef311a2a8fbe (diff)
downloadchef-dffde98d6228ccb4ea1dbd19d4db08edc62625b8.tar.gz
remove dependency on Chef.run_context global state
introduce run_context.root_run_context that avoids global state Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/run_context.rb')
-rw-r--r--lib/chef/run_context.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb
index 5d29f766c9..0ebf1b228d 100644
--- a/lib/chef/run_context.rb
+++ b/lib/chef/run_context.rb
@@ -85,6 +85,19 @@ class Chef
attr_reader :parent_run_context
#
+ # The root run context.
+ #
+ # @return [Chef::RunContext] The root run context.
+ #
+ def root_run_context
+ rc = self
+ until rc.parent_run_context.nil?
+ rc = rc.parent_run_context
+ end
+ rc
+ end
+
+ #
# The collection of resources intended to be converged (and able to be
# notified).
#