Class: Puppet::Util::Ldap::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/util/ldap/generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Generator

Initialize our generator with the name of the parameter being generated.



22
23
24
# File 'lib/puppet/util/ldap/generator.rb', line 22

def initialize(name)
  @name = name
end

Instance Method Details

#from(source) ⇒ Object

Declare the attribute we’ll use to generate the value.



6
7
8
9
# File 'lib/puppet/util/ldap/generator.rb', line 6

def from(source)
  @source = source
  self
end

#generate(value = nil) ⇒ Object

Actually do the generation.



12
13
14
15
16
17
18
# File 'lib/puppet/util/ldap/generator.rb', line 12

def generate(value = nil)
  if value.nil?
    @generator.call
  else
    @generator.call(value)
  end
end

#nameObject



26
27
28
# File 'lib/puppet/util/ldap/generator.rb', line 26

def name
  @name.to_s
end

#sourceObject



30
31
32
33
34
35
36
# File 'lib/puppet/util/ldap/generator.rb', line 30

def source
  if @source
    @source.to_s
  else
    nil
  end
end

#with(&block) ⇒ Object

Provide the code that does the generation.



39
40
41
42
# File 'lib/puppet/util/ldap/generator.rb', line 39

def with(&block)
  @generator = block
  self
end