summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-04-18 15:52:11 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2016-04-18 15:52:11 -0700
commit7935d72de42bb7c9e5ac7332b4db4f9fb0ce7d5f (patch)
treeeb91915a5273e6870e08c0affab0a588bc785039
parente421b0438177dada513acf7f21f10ba2b3a8f4be (diff)
downloadchef-7935d72de42bb7c9e5ac7332b4db4f9fb0ce7d5f.tar.gz
fix details in with_run_context
-rw-r--r--lib/chef/dsl/declare_resource.rb14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb
index 9b51161a75..dbc05074c0 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
@@ -273,7 +273,7 @@ class Chef
run_context: run_context,
cookbook_name: cookbook_name,
recipe_name: recipe_name,
- enclosing_provider: self.is_a?(Chef::Provider) ? self : nil
+ enclosing_provider: self.is_a?(Chef::Provider) ? self : nil,
).build(&resource_attrs_block)
end
end