summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2015-12-07 18:17:38 +0000
committerThom May <thom@may.lt>2015-12-07 18:17:38 +0000
commitdae24eeaf0c03b5ae2009ec38306a4e63e8ba1be (patch)
tree36c9986ffc8fbb74af7b686db7157b680280b3d7
parent5b0f23f56aeb4eec2c4bea29a3d4ff93caa4c11b (diff)
parent57c7bf84ca02a8bd5a10dd6e8e12689ee5a97812 (diff)
downloadchef-dae24eeaf0c03b5ae2009ec38306a4e63e8ba1be.tar.gz
Merge pull request #4243 from chef/jk/fix-resource-super
Fix resource `super` (broken because of test :focus)
-rw-r--r--lib/chef/provider.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
index 3ddf33844f..68bc8d78bd 100644
--- a/lib/chef/provider.rb
+++ b/lib/chef/provider.rb
@@ -376,7 +376,18 @@ class Chef
# compile the resources, converging them, and then checking if any
# were updated (and updating new-resource if so)
def action(name, &block)
- define_method("action_#{name}") { compile_and_converge_action(&block) }
+ # We need the block directly in a method so that `super` works
+ define_method("compile_action_#{name}", &block)
+ # We try hard to use `def` because define_method doesn't show the method name in the stack.
+ begin
+ class_eval <<-EOM
+ def action_#{name}
+ compile_and_converge_action { compile_action_#{name} }
+ end
+ EOM
+ rescue SyntaxError
+ define_method("action_#{name}") { send("compile_action_#{name}") }
+ end
end
end