blob: da0d213fbd48bda227b1839c4dcc5d8b0f6f46cc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
require 'puppet/string/option'
class Puppet::String::OptionBuilder
attr_reader :option
def self.build(string, *declaration, &block)
new(string, *declaration, &block).option
end
private
def initialize(string, *declaration, &block)
@string = string
@option = Puppet::String::Option.new(string, *declaration)
block and instance_eval(&block)
@option
end
# Metaprogram the simple DSL from the option class.
Puppet::String::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
|