Class: Puppet::Pops::FirstFoundStrategy
- Inherits:
-
MergeStrategy
- Object
- MergeStrategy
- Puppet::Pops::FirstFoundStrategy
- Defined in:
- lib/puppet/pops/merge_strategy.rb
Overview
Simple strategy that returns the first value found. It never merges any values.
Direct Known Subclasses
Constant Summary collapse
- INSTANCE =
new(EMPTY_HASH)
Constants inherited from MergeStrategy
Class Method Summary collapse
Instance Method Summary collapse
-
#lookup(lookup_variants, _) ⇒ Object
Returns the first value found.
Methods inherited from MergeStrategy
add_strategy, #configuration, #convert_value, #initialize, merge, #merge, #merge_lookup, #merge_single, #options, options_t, strategy, strategy_keys
Constructor Details
This class inherits a constructor from Puppet::Pops::MergeStrategy
Class Method Details
.key ⇒ Object
213 214 215 |
# File 'lib/puppet/pops/merge_strategy.rb', line 213 def self.key :first end |
Instance Method Details
#lookup(lookup_variants, _) ⇒ Object
Returns the first value found
223 224 225 226 227 228 |
# File 'lib/puppet/pops/merge_strategy.rb', line 223 def lookup(lookup_variants, _) # First found does not continue when a root key was found and a subkey wasn't since that would # simulate a hash merge lookup_variants.each { |lookup_variant| catch(:no_such_key) { return yield(lookup_variant) } } throw :no_such_key end |