Class: Hiera::Scope
- Extended by:
- Forwardable
- Defined in:
- lib/hiera/scope.rb
Constant Summary collapse
- CALLING_CLASS =
'calling_class'
- CALLING_CLASS_PATH =
'calling_class_path'
- CALLING_MODULE =
'calling_module'
- MODULE_NAME =
'module_name'
- CALLING_KEYS =
[CALLING_CLASS, CALLING_CLASS_PATH, CALLING_MODULE].freeze
- EMPTY_STRING =
''
Instance Attribute Summary collapse
-
#real ⇒ Object
readonly
Returns the value of attribute real.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #catalog ⇒ Object
- #compiler ⇒ Object
- #exist?(key) ⇒ Boolean
- #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.
18 19 20 |
# File 'lib/hiera/scope.rb', line 18 def initialize(real) @real = real end |
Instance Attribute Details
#real ⇒ Object (readonly)
Returns the value of attribute real.
16 17 18 |
# File 'lib/hiera/scope.rb', line 16 def real @real end |
Instance Method Details
#[](key) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/hiera/scope.rb', line 22 def [](key) case key when CALLING_CLASS ans = find_hostclass(@real) when CALLING_CLASS_PATH ans = find_hostclass(@real).gsub(/::/, '/') when CALLING_MODULE ans = safe_lookupvar(MODULE_NAME) else ans = safe_lookupvar(key) end ans == EMPTY_STRING ? nil : ans end |
#catalog ⇒ Object
66 67 68 |
# File 'lib/hiera/scope.rb', line 66 def catalog @real.catalog end |
#compiler ⇒ Object
74 75 76 |
# File 'lib/hiera/scope.rb', line 74 def compiler @real.compiler end |
#exist?(key) ⇒ Boolean
58 59 60 |
# File 'lib/hiera/scope.rb', line 58 def exist?(key) CALLING_KEYS.include?(key) || @real.exist?(key) end |
#include?(key) ⇒ Boolean
62 63 64 |
# File 'lib/hiera/scope.rb', line 62 def include?(key) CALLING_KEYS.include?(key) || @real.include?(key) end |
#resource ⇒ Object
70 71 72 |
# File 'lib/hiera/scope.rb', line 70 def resource @real.resource end |