blob: 608d72974fd6815ad25d70ae5c5040e2576cd541 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
require 'puppet/util/ldap'
class Puppet::Util::Ldap::Generator
# Declare the attribute we'll use to generate the value.
def from(source)
@source = source
self
end
# Actually do the generation.
def generate(value = nil)
if value.nil?
@generator.call
else
@generator.call(value)
end
end
# Initialize our generator with the name of the parameter
# being generated.
def initialize(name)
@name = name
end
def name
@name.to_s
end
def source
if @source
@source.to_s
else
nil
end
end
# Provide the code that does the generation.
def with(&block)
@generator = block
self
end
end
|