Class: Puppet::Util::Hiera::Scope
- Inherits:
-
Object
- Object
- Puppet::Util::Hiera::Scope
- Defined in:
- lib/puppet/util/hiera/scope.rb
Constant Summary collapse
- HIERA_MODULE_NAME =
"::hiera_module"
Instance Attribute Summary collapse
-
#hiera_module ⇒ Object
Returns the value of attribute hiera_module.
-
#real ⇒ Object
readonly
Returns the value of attribute real.
-
#stage_name ⇒ Object
writeonly
Sets the attribute stage_name.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #catalog ⇒ Object
- #compiler ⇒ Object
- #get_hiera_lookup_name(lookup) ⇒ Object
- #get_hiera_lookup_names(lookup) ⇒ Object
- #get_hiera_module_name ⇒ Object
- #get_hiera_name ⇒ Object
- #include?(key) ⇒ Boolean
-
#initialize(real) ⇒ Scope
constructor
A new instance of Scope.
- #lookupvar(key) ⇒ Object
- #resource ⇒ Object
Constructor Details
#initialize(real) ⇒ Scope
Returns a new instance of Scope.
8 9 10 11 |
# File 'lib/puppet/util/hiera/scope.rb', line 8 def initialize(real) @real = real @stage_name = '' end |
Instance Attribute Details
#hiera_module ⇒ Object
Returns the value of attribute hiera_module.
5 6 7 |
# File 'lib/puppet/util/hiera/scope.rb', line 5 def hiera_module @hiera_module end |
#real ⇒ Object (readonly)
Returns the value of attribute real.
4 5 6 |
# File 'lib/puppet/util/hiera/scope.rb', line 4 def real @real end |
#stage_name=(value) ⇒ Object (writeonly)
Sets the attribute stage_name
6 7 8 |
# File 'lib/puppet/util/hiera/scope.rb', line 6 def stage_name=(value) @stage_name = value end |
Instance Method Details
#[](key) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/puppet/util/hiera/scope.rb', line 44 def [](key) if key == HIERA_MODULE_NAME and @hiera_module ans = get_hiera_module_name() else ans = @real.lookupvar(key) end if ans.nil? or ans == "" nil else ans end end |
#catalog ⇒ Object
74 75 76 |
# File 'lib/puppet/util/hiera/scope.rb', line 74 def catalog @real.catalog end |
#compiler ⇒ Object
82 83 84 |
# File 'lib/puppet/util/hiera/scope.rb', line 82 def compiler @real.compiler end |
#get_hiera_lookup_name(lookup) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/puppet/util/hiera/scope.rb', line 27 def get_hiera_lookup_name(lookup) if @hiera_module "#{get_hiera_name()}::#{lookup}" else lookup end end |
#get_hiera_lookup_names(lookup) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/puppet/util/hiera/scope.rb', line 35 def get_hiera_lookup_names(lookup) res = @hiera_module.get_hiera_names().map{|v| "#{v}::#{lookup}"} if @stage_name != 'default' res.map!{|v| "#{@stage_name}::#{v}"} res << "#{@stage_name}::#{lookup}" end res << lookup end |
#get_hiera_module_name ⇒ Object
13 14 15 |
# File 'lib/puppet/util/hiera/scope.rb', line 13 def get_hiera_module_name @hiera_module.name end |
#get_hiera_name ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/puppet/util/hiera/scope.rb', line 17 def get_hiera_name res = '' res += @stage_name if @stage_name != 'default' if @hiera_module res += '::' if res != '' res += @hiera_module.get_hiera_name() end return res end |
#include?(key) ⇒ Boolean
58 59 60 61 62 63 64 |
# File 'lib/puppet/util/hiera/scope.rb', line 58 def include?(key) if key == HIERA_MODULE_NAME and @hiera_module true else @real.lookupvar(key) != "" end end |
#lookupvar(key) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/puppet/util/hiera/scope.rb', line 66 def lookupvar(key) if key == HIERA_MODULE_NAME and @hiera_module get_hiera_module_name() else @real.lookupvar(key) end end |
#resource ⇒ Object
78 79 80 |
# File 'lib/puppet/util/hiera/scope.rb', line 78 def resource @real.resource end |