From 7935d72de42bb7c9e5ac7332b4db4f9fb0ce7d5f Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 18 Apr 2016 15:52:11 -0700 Subject: fix details in with_run_context --- lib/chef/dsl/declare_resource.rb | 14 +++++++------- 1 file 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 -- cgit v1.2.1 From af36eecfa3b4643e4c33f96d91d66b9dfdd2f931 Mon Sep 17 00:00:00 2001 From: Lamont Granquist Date: Mon, 18 Apr 2016 20:51:37 -0700 Subject: how did that get there? --- lib/chef/dsl/declare_resource.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb index dbc05074c0..8d76ddfb31 100644 --- a/lib/chef/dsl/declare_resource.rb +++ b/lib/chef/dsl/declare_resource.rb @@ -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 -- cgit v1.2.1