Class: Puppet::Settings::ChainedValues
Overview
Lookup configuration setting value through a chain of different value sources.
Constant Summary collapse
- ENVIRONMENT_SETTING =
"environment"
- 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.
1428 1429 1430 1431 1432 1433 |
# File 'lib/puppet/settings.rb', line 1428 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.
1468 1469 1470 1471 1472 1473 1474 1475 |
# File 'lib/puppet/settings.rb', line 1468 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.
1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 |
# File 'lib/puppet/settings.rb', line 1440 def lookup(name) set = @value_sets.find do |value_set| value_set.include?(name) end if set value = set.lookup(name) unless value.nil? return value end end setting = @defaults[name] if setting.respond_to?(:alias_name) val = lookup(setting.alias_name) return val if val end @defaults[name].default end |
#print(name) ⇒ Object
1477 1478 1479 1480 1481 1482 1483 1484 |
# File 'lib/puppet/settings.rb', line 1477 def print(name) setting = @defaults[name] return nil unless setting lookup_and_convert(name) do |val| setting.print(val) end end |