From 633f63cdbc1d5630e546041bb0c1e714216158d0 Mon Sep 17 00:00:00 2001 From: Daniel Pittman Date: Thu, 24 Mar 2011 13:33:30 -0700 Subject: (#6833) support 'script' as a short form of 'action' At the moment the action method is a fairly heavy tool: it provides a DSL, and is designed to allow substantial metadata to be added to the action. For some users this is low on value, since they just want to write a little script that drives things a bit differently. Which there is substantial value in the metadata, adding the capability to do these light-weight things quickly is valid. To meet this we add a script action; the contrast is: action :foo do # other metadata goes here invoke do |args| # method body goes here end end script :bar do |args| # method body goes here end # ...and if you want metadata, you have to add it in more ugly, procedural # ways, which we are not going to encourage. Reviewed-By: Pieter van de Bruggen --- lib/puppet/interface/action_builder.rb | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'lib/puppet/interface/action_builder.rb') diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb index e76fb1c6e..e389ea3ea 100644 --- a/lib/puppet/interface/action_builder.rb +++ b/lib/puppet/interface/action_builder.rb @@ -18,13 +18,10 @@ class Puppet::Interface::ActionBuilder end # Ideally the method we're defining here would be added to the action, and a - # method on the interface would defer to it + # method on the interface would defer to it, but we can't get scope correct, + # so we stick with this. --daniel 2011-03-24 def invoke(&block) raise "Invoke called on an ActionBuilder with no corresponding Action" unless @action - if @interface.is_a?(Class) - @interface.define_method(@action.name, &block) - else - @interface.meta_def(@action.name, &block) - end + @action.invoke = block end end -- cgit