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.



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

def initialize(name)
  @name = name
end

Instance Method Details

#from(source) ⇒ Object

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



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

def from(source)
  @source = source
  self
end

#generate(value = nil) ⇒ Object

Actually do the generation.



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

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

#nameObject



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

def name
  @name.to_s
end

#sourceObject



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

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

#with(&block) ⇒ Object

Provide the code that does the generation.



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

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