Class: Puppet::Settings::ChainedValues
Overview
Lookup configuration setting value through a chain of different value sources.
Constant Summary collapse
- ENVIRONMENT_SETTING =
"environment".freeze
- ENVIRONMENT_INTERPOLATION_ALLOWED =
['config_version'].freeze
Instance Method Summary collapse
-
#initialize(mode, environment, value_sets, defaults) ⇒ ChainedValues
constructor
private
A new instance of ChainedValues.
-
#interpolate(name) ⇒ Object
Lookup the interpolated value.
-
#lookup(name) ⇒ Object
Lookup the uninterpolated value.
- #print(name) ⇒ Object
Constructor Details
#initialize(mode, environment, value_sets, defaults) ⇒ ChainedValues
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of ChainedValues.
1337 1338 1339 1340 1341 1342 |
# File 'lib/puppet/settings.rb', line 1337 def initialize(mode, environment, value_sets, defaults) @mode = mode @environment = environment @value_sets = value_sets @defaults = defaults end |
Instance Method Details
#interpolate(name) ⇒ Object
Lookup the interpolated value. All instances of ‘$name` in the value will be replaced by performing a lookup of `name` and substituting the text for `$name` in the original value. This interpolation is only performed if the looked up value is a String.
1371 1372 1373 1374 1375 1376 1377 1378 |
# File 'lib/puppet/settings.rb', line 1371 def interpolate(name) setting = @defaults[name] return nil unless setting lookup_and_convert(name) do |val| setting.munge(val) end end |
#lookup(name) ⇒ Object
Lookup the uninterpolated value.
1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 |
# File 'lib/puppet/settings.rb', line 1349 def lookup(name) set = @value_sets.find do |value_set| value_set.include?(name) end if set value = set.lookup(name) if !value.nil? return value end end @defaults[name].default end |
#print(name) ⇒ Object
1380 1381 1382 1383 1384 1385 1386 1387 |
# File 'lib/puppet/settings.rb', line 1380 def print(name) setting = @defaults[name] return nil unless setting lookup_and_convert(name) do |val| setting.print(val) end end |