Class: Hiera::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/hiera/scope.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(real) ⇒ Scope

Returns a new instance of Scope.



5
6
7
# File 'lib/hiera/scope.rb', line 5

def initialize(real)
  @real = real
end

Instance Attribute Details

#realObject (readonly)

Returns the value of attribute real.



3
4
5
# File 'lib/hiera/scope.rb', line 3

def real
  @real
end

Instance Method Details

#[](key) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/hiera/scope.rb', line 9

def [](key)
  if key == "calling_class"
    ans = @real.resource.name.to_s.downcase
  elsif key == "calling_module"
    ans = @real.resource.name.to_s.downcase.split("::").first
  else
    ans = @real.lookupvar(key)
  end

  # damn you puppet visual basic style variables.
  return nil if ans == ""
  return ans
end

#catalogObject



29
30
31
# File 'lib/hiera/scope.rb', line 29

def catalog
  @real.catalog
end

#compilerObject



37
38
39
# File 'lib/hiera/scope.rb', line 37

def compiler
  @real.compiler
end

#include?(key) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/hiera/scope.rb', line 23

def include?(key)
  return true if ["calling_class", "calling_module"].include?(key)

  return @real.lookupvar(key) != ""
end

#resourceObject



33
34
35
# File 'lib/hiera/scope.rb', line 33

def resource
  @real.resource
end