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 =
self.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, strategy, strategy_keys
Constructor Details
This class inherits a constructor from Puppet::Pops::MergeStrategy
Class Method Details
.key ⇒ Object
203 204 205 |
# File 'lib/puppet/pops/merge_strategy.rb', line 203 def self.key :first end |
Instance Method Details
#lookup(lookup_variants, _) ⇒ Object
Returns the first value found
213 214 215 216 217 218 |
# File 'lib/puppet/pops/merge_strategy.rb', line 213 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 |