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.



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

def initialize(name)
  @name = name
end

Instance Method Details

#from(source) ⇒ Object

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



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

def from(source)
  @source = source
  self
end

#generate(value = nil) ⇒ Object

Actually do the generation.



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

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

#nameObject



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

def name
  @name.to_s
end

#sourceObject



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

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

#with(&block) ⇒ Object

Provide the code that does the generation.



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

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