summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-02 17:56:48 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-02 17:56:48 -0800
commitcbb0a78d9b3f860943b11a3769c7cfff91f4e820 (patch)
tree6455a8381417b0eafc4e09da2559f4f43018739b /lib
parentab63cd4be967b5d01f6ec856244e4b9af4e896d9 (diff)
downloadchef-cbb0a78d9b3f860943b11a3769c7cfff91f4e820.tar.gz
add Resource#apply for applying blocks
Example: modes = proc { mode "0644"; group "root"; owner "root" } file "/tmp/whatever" do apply modes end
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/resource.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 1791e4143e..b3c3fd4429 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1461,6 +1461,19 @@ class Chef
end
end
+ # Apply a proc or block to the resource.
+ #
+ # modes = proc { mode "0644"; group "root"; owner "root" }
+ # file "/tmp/whatever" do
+ # apply modes
+ # end
+ #
+ # @method apply(proc, &block)
+ def apply(prok=nil, &block)
+ block ||= prok
+ self.instance_eval(&block)
+ end
+
#
# Preface an exception message with generic Resource information.
#