class Puppet::Pops::Lookup::DataDigFunctionProvider
@api private
Constants
- TAG
Public Instance Methods
invoke_with_location(lookup_invocation, location, key, merge)
click to toggle source
# File lib/puppet/pops/lookup/data_dig_function_provider.rb 25 def invoke_with_location(lookup_invocation, location, key, merge) 26 if location.nil? 27 key.undig(lookup_invocation.report_found(key, validated_data_dig(key, lookup_invocation, nil, merge))) 28 else 29 lookup_invocation.with(:location, location) do 30 key.undig(lookup_invocation.report_found(key, validated_data_dig(key, lookup_invocation, location, merge))) 31 end 32 end 33 end
label()
click to toggle source
# File lib/puppet/pops/lookup/data_dig_function_provider.rb 35 def label 36 'Data Dig' 37 end
unchecked_key_lookup(key, lookup_invocation, merge)
click to toggle source
Performs a lookup with the assumption that a recursive check has been made.
@param key [LookupKey] The key to lookup @param lookup_invocation [Invocation] The current lookup invocation @param merge [MergeStrategy,String,Hash{String => Object},nil] Merge strategy, merge strategy name, strategy and options hash, or nil (implies “first found”) @return [Object] the found object @throw :no_such_key when the object is not found
# File lib/puppet/pops/lookup/data_dig_function_provider.rb 17 def unchecked_key_lookup(key, lookup_invocation, merge) 18 lookup_invocation.with(:data_provider, self) do 19 MergeStrategy.strategy(merge).lookup(locations, lookup_invocation) do |location| 20 invoke_with_location(lookup_invocation, location, key, merge) 21 end 22 end 23 end
validated_data_dig(key, lookup_invocation, location, merge)
click to toggle source
# File lib/puppet/pops/lookup/data_dig_function_provider.rb 39 def validated_data_dig(key, lookup_invocation, location, merge) 40 validate_data_value(data_dig(key, lookup_invocation, location, merge)) do 41 msg = "Value for key '#{key}', returned from #{full_name}" 42 location.nil? ? msg : "#{msg}, when using location '#{location}'," 43 end 44 end
Private Instance Methods
data_dig(key, lookup_invocation, location, merge)
click to toggle source
# File lib/puppet/pops/lookup/data_dig_function_provider.rb 48 def data_dig(key, lookup_invocation, location, merge) 49 unless location.nil? || location.exist? 50 lookup_invocation.report_location_not_found 51 throw :no_such_key 52 end 53 ctx = function_context(lookup_invocation, location) 54 ctx.data_hash ||= {} 55 catch(:no_such_key) do 56 hash = ctx.data_hash 57 hash[key] = ctx.function.call(lookup_invocation.scope, key.to_a, options(location), Context.new(ctx, lookup_invocation)) unless hash.include?(key) 58 return hash[key] 59 end 60 lookup_invocation.report_not_found(key) 61 throw :no_such_key 62 end