summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-04-19 10:00:53 +0100
committerThom May <thom@may.lt>2016-04-19 10:00:53 +0100
commitaa2a7cc405a7190f942f5268ff287fdd7f2b4e3b (patch)
treed20902d9cd09cc5dcdffe134b2b1882950504a0c
parente2bf6de08ed496ea7b5f977afa648abd673ea521 (diff)
parentaf36eecfa3b4643e4c33f96d91d66b9dfdd2f931 (diff)
downloadchef-aa2a7cc405a7190f942f5268ff287fdd7f2b4e3b.tar.gz
Merge pull request #4839 from chef/lcg/fix-resources-api-issues
fix details in with_run_context
-rw-r--r--lib/chef/dsl/declare_resource.rb12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb
index 9b51161a75..8d76ddfb31 100644
--- a/lib/chef/dsl/declare_resource.rb
+++ b/lib/chef/dsl/declare_resource.rb
@@ -39,9 +39,9 @@ class Chef
# end
# end
#
- def with_run_context(rc, &block)
+ def with_run_context(rc)
raise ArgumentError, "with_run_context is useless without a block" unless block_given?
- @old_run_context = @run_context
+ old_run_context = @run_context
@run_context =
case rc
when Chef::RunContext
@@ -51,11 +51,11 @@ class Chef
when :parent
run_context.parent_run_context
else
- raise "bad argument to run_context helper, must be :root, :parent, or a Chef::RunContext"
+ raise ArgumentError, "bad argument to run_context helper, must be :root, :parent, or a Chef::RunContext"
end
- ret = yield
- @run_context = @old_run_context
- ret
+ yield
+ ensure
+ @run_context = old_run_context
end
# Lookup a resource in the resource collection by name and delete it. This