summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-12-06 15:27:55 -0800
committerJohn Keiser <john@johnkeiser.com>2015-12-06 15:27:55 -0800
commit57c7bf84ca02a8bd5a10dd6e8e12689ee5a97812 (patch)
treed9d5403a39506cb03f0d24a926c144f6de530b8f
parent691d0b8c14816316a814823c6113b74e89360662 (diff)
downloadchef-jk/fix-resource-super.tar.gz
Fix resource `super` (broken because of test :focus)jk/fix-resource-super
-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