blob: 781c1eb3a5ddb60563c9baac8da3f0a270757fcd (
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
class Hiera
class Scope
CALLING_CLASS = "calling_class"
CALLING_MODULE = "calling_module"
MODULE_NAME = "module_name"
attr_reader :real
def initialize(real)
@real = real
end
def [](key)
if key == CALLING_CLASS
ans = find_hostclass(@real)
elsif key == CALLING_MODULE
ans = @real.lookupvar(MODULE_NAME)
else
ans = @real.lookupvar(key)
end
if ans.nil? or ans == ""
nil
else
ans
end
end
def include?(key)
if key == CALLING_CLASS or key == CALLING_MODULE
true
else
@real.lookupvar(key) != ""
end
end
def catalog
@real.catalog
end
def resource
@real.resource
end
def compiler
@real.compiler
end
def find_hostclass(scope)
if scope.source and scope.source.type == :hostclass
return scope.source.name.downcase
elsif scope.parent
return find_hostclass(scope.parent)
else
return nil
end
end
private :find_hostclass
end
end
|