Class: Hiera::Scope
Constant Summary collapse
- CALLING_CLASS =
'calling_class'.freeze
- CALLING_CLASS_PATH =
'calling_class_path'.freeze
- CALLING_MODULE =
'calling_module'.freeze
- MODULE_NAME =
'module_name'.freeze
- CALLING_KEYS =
[CALLING_CLASS, CALLING_CLASS_PATH, CALLING_MODULE].freeze
- EMPTY_STRING =
''.freeze
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.
13 14 15 |
# File 'lib/hiera/scope.rb', line 13 def initialize(real) @real = real end |
Instance Attribute Details
#real ⇒ Object (readonly)
Returns the value of attribute real.
11 12 13 |
# File 'lib/hiera/scope.rb', line 11 def real @real end |
Instance Method Details
#[](key) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/hiera/scope.rb', line 17 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 = safe_lookupvar(MODULE_NAME) else ans = safe_lookupvar(key) end ans == EMPTY_STRING ? nil : ans end |
#catalog ⇒ Object
60 61 62 |
# File 'lib/hiera/scope.rb', line 60 def catalog @real.catalog end |
#compiler ⇒ Object
68 69 70 |
# File 'lib/hiera/scope.rb', line 68 def compiler @real.compiler end |
#exist?(key) ⇒ Boolean
52 53 54 |
# File 'lib/hiera/scope.rb', line 52 def exist?(key) CALLING_KEYS.include?(key) || @real.exist?(key) end |
#include?(key) ⇒ Boolean
56 57 58 |
# File 'lib/hiera/scope.rb', line 56 def include?(key) CALLING_KEYS.include?(key) || @real.include?(key) end |
#resource ⇒ Object
64 65 66 |
# File 'lib/hiera/scope.rb', line 64 def resource @real.resource end |