Class: Hiera::Scope
Constant Summary collapse
- CALLING_CLASS =
"calling_class"
- CALLING_CLASS_PATH =
"calling_class_path"
- CALLING_MODULE =
"calling_module"
- MODULE_NAME =
"module_name"
Instance Attribute Summary collapse
-
#real ⇒ Object
readonly
Returns the value of attribute real.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #catalog ⇒ Object
- #compiler ⇒ Object
- #include?(key) ⇒ Boolean
-
#initialize(real) ⇒ Scope
constructor
A new instance of Scope.
- #resource ⇒ Object
Constructor Details
#initialize(real) ⇒ Scope
Returns a new instance of Scope.
10 11 12 |
# File 'lib/hiera/scope.rb', line 10 def initialize(real) @real = real end |
Instance Attribute Details
#real ⇒ Object (readonly)
Returns the value of attribute real.
8 9 10 |
# File 'lib/hiera/scope.rb', line 8 def real @real end |
Instance Method Details
#[](key) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/hiera/scope.rb', line 14 def [](key) if key == CALLING_CLASS ans = find_hostclass(@real) elsif key == CALLING_CLASS_PATH ans = find_hostclass(@real).gsub(/::/, '/') 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 |
#catalog ⇒ Object
40 41 42 |
# File 'lib/hiera/scope.rb', line 40 def catalog @real.catalog end |
#compiler ⇒ Object
48 49 50 |
# File 'lib/hiera/scope.rb', line 48 def compiler @real.compiler end |
#include?(key) ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/hiera/scope.rb', line 32 def include?(key) if [CALLING_CLASS, CALLING_CLASS_PATH, CALLING_MODULE].include? key true else @real.lookupvar(key) != "" end end |
#resource ⇒ Object
44 45 46 |
# File 'lib/hiera/scope.rb', line 44 def resource @real.resource end |