Initialize our generator with the name of the parameter being generated.
# File lib/puppet/util/ldap/generator.rb, line 21 def initialize(name) @name = name end
Declare the attribute we’ll use to generate the value.
# File lib/puppet/util/ldap/generator.rb, line 5 def from(source) @source = source self end
Actually do the generation.
# File lib/puppet/util/ldap/generator.rb, line 11 def generate(value = nil) if value.nil? @generator.call else @generator.call(value) end end
# File lib/puppet/util/ldap/generator.rb, line 25 def name @name.to_s end
# File lib/puppet/util/ldap/generator.rb, line 29 def source if @source @source.to_s else nil end end
Provide the code that does the generation.
# File lib/puppet/util/ldap/generator.rb, line 38 def with(&block) @generator = block self end