diff options
| author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-29 17:24:18 -0700 |
|---|---|---|
| committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-05-02 10:08:26 -0700 |
| commit | b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da (patch) | |
| tree | a0c8310b9a36b51c2566dfa7ef86ab421658ddd7 /lib/puppet/interface | |
| parent | 6815044fbc94c0d502b1061309d5aaeb8f791660 (diff) | |
| download | puppet-b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da.tar.gz puppet-b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da.tar.xz puppet-b23cc8abec1a1ec41b554b4e72f9a3c21feaf9da.zip | |
(#7282) action without `when_invoked` should fail...
We used to let actions be declared without the `when_invoked` block, which was
usually a sign of either someone writing their method code direct in action
declaration, or someone forgetting to add their code at all.
This was just let silently by: the error only showed up when you finally tried
to invoke the action, and a NoMethod error was raised by the face.
...except for our own testing. We took advantage of this a whole pile of
times in there; fixing the original UI issue means fixing all those too.
Reviewed-By: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'lib/puppet/interface')
| -rw-r--r-- | lib/puppet/interface/action.rb | 5 | ||||
| -rw-r--r-- | lib/puppet/interface/action_builder.rb | 1 |
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/puppet/interface/action.rb b/lib/puppet/interface/action.rb index 0dbdd57bb..203d80827 100644 --- a/lib/puppet/interface/action.rb +++ b/lib/puppet/interface/action.rb @@ -171,7 +171,8 @@ class Puppet::Interface::Action # this stuff work, because it would have been cleaner. Which gives you an # idea how motivated we were to make this cleaner. Sorry. # --daniel 2011-03-31 - attr_reader :positional_arg_count + attr_reader :positional_arg_count + attr_accessor :when_invoked def when_invoked=(block) internal_name = "#{@name} implementation, required on Ruby 1.8".to_sym @@ -219,9 +220,11 @@ WRAPPER if @face.is_a?(Class) @face.class_eval do eval wrapper, nil, file, line end @face.define_method(internal_name, &block) + @when_invoked = @face.instance_method(name) else @face.instance_eval do eval wrapper, nil, file, line end @face.meta_def(internal_name, &block) + @when_invoked = @face.method(name).unbind end end diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb index afc49e945..0bf4f1408 100644 --- a/lib/puppet/interface/action_builder.rb +++ b/lib/puppet/interface/action_builder.rb @@ -69,5 +69,6 @@ class Puppet::Interface::ActionBuilder @face = face @action = Puppet::Interface::Action.new(face, name) instance_eval(&block) + @action.when_invoked or raise ArgumentError, "actions need to know what to do when_invoked; please add the block" end end |
