diff options
author | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-07 15:53:17 -0700 |
---|---|---|
committer | Daniel Pittman <daniel@puppetlabs.com> | 2011-04-07 15:53:17 -0700 |
commit | a35fa519c85a761ac8bed3be8fde2d6523cae474 (patch) | |
tree | 36f3583ee364ba1d68467a2b614a8dfcf9ed43ae /lib/puppet/interface/option_builder.rb | |
parent | 3d5ec4f61fee08552767e950ac021752c202a599 (diff) | |
parent | 87ed3188e65d3f5f9c2c32a409b271d1b39684b9 (diff) | |
download | puppet-a35fa519c85a761ac8bed3be8fde2d6523cae474.tar.gz puppet-a35fa519c85a761ac8bed3be8fde2d6523cae474.tar.xz puppet-a35fa519c85a761ac8bed3be8fde2d6523cae474.zip |
Merge branch 'refactor/master/7012-rename-strings-to-interfaces-and-faces'
Diffstat (limited to 'lib/puppet/interface/option_builder.rb')
-rw-r--r-- | lib/puppet/interface/option_builder.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/puppet/interface/option_builder.rb b/lib/puppet/interface/option_builder.rb new file mode 100644 index 000000000..83a1906b0 --- /dev/null +++ b/lib/puppet/interface/option_builder.rb @@ -0,0 +1,25 @@ +require 'puppet/interface/option' + +class Puppet::Interface::OptionBuilder + attr_reader :option + + def self.build(face, *declaration, &block) + new(face, *declaration, &block).option + end + + private + def initialize(face, *declaration, &block) + @face = face + @option = Puppet::Interface::Option.new(face, *declaration) + block and instance_eval(&block) + @option + end + + # Metaprogram the simple DSL from the option class. + Puppet::Interface::Option.instance_methods.grep(/=$/).each do |setter| + next if setter =~ /^=/ # special case, darn it... + + dsl = setter.sub(/=$/, '') + define_method(dsl) do |value| @option.send(setter, value) end + end +end |