From bbf777f5f47b98d35fbbc7b8e3983d79af559017 Mon Sep 17 00:00:00 2001 From: Pieter van de Bruggen Date: Tue, 26 Apr 2011 16:07:21 -0700 Subject: (#7249) Publicize ActionBuilder DSL methods. This change permits users to call functions with a reference to `self` that can augment the in-progress action declaration, which can be helpful in some more involved cases. Reviewed-By: Max Martin Reviewed-By: Daniel Pittman --- lib/puppet/interface/action_builder.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'lib/puppet/interface') diff --git a/lib/puppet/interface/action_builder.rb b/lib/puppet/interface/action_builder.rb index 2ffa38709..afc49e945 100644 --- a/lib/puppet/interface/action_builder.rb +++ b/lib/puppet/interface/action_builder.rb @@ -9,13 +9,6 @@ class Puppet::Interface::ActionBuilder new(face, name, &block).action end - private - def initialize(face, name, &block) - @face = face - @action = Puppet::Interface::Action.new(face, name) - instance_eval(&block) - end - # Ideally the method we're defining here would be added to the action, and a # method on the face would defer to it, but we can't get scope correct, so # we stick with this. --daniel 2011-03-24 @@ -56,18 +49,25 @@ class Puppet::Interface::ActionBuilder # Metaprogram the simple DSL from the target class. Puppet::Interface::Action.instance_methods.grep(/=$/).each do |setter| next if setter =~ /^=/ - dsl = setter.sub(/=$/, '') + property = setter.sub(/=$/, '') - unless private_instance_methods.include? dsl + unless public_instance_methods.include? property # Using eval because the argument handling semantics are less awful than # when we use the define_method/block version. The later warns on older # Ruby versions if you pass the wrong number of arguments, but carries # on, which is totally not what we want. --daniel 2011-04-18 - eval <