Class: Puppet::Pops::Lookup::ModuleDataProvider Private
- Inherits:
-
ConfiguredDataProvider
- Object
- ConfiguredDataProvider
- Puppet::Pops::Lookup::ModuleDataProvider
- Defined in:
- lib/puppet/pops/lookup/module_data_provider.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #module_name ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(module_name, config = nil) ⇒ ModuleDataProvider
constructor
private
A new instance of ModuleDataProvider.
-
#key_lookup_in_default(key, lookup_invocation, merge) ⇒ Object
private
Performs a lookup using a module default hierarchy with an endless recursion check.
- #place ⇒ Object private
-
#validate_data_hash(data_hash) ⇒ Hash
private
Asserts that all keys in the given data_hash are prefixed with the configured module_name.
Methods inherited from ConfiguredDataProvider
#config, #config=, #config_path, #name, #unchecked_key_lookup
Methods included from DataProvider
#key_lookup, key_type, #lookup, #name, register_types, #unchecked_key_lookup, #validate_data_value, #value_is_validated?, value_type
Constructor Details
#initialize(module_name, config = nil) ⇒ ModuleDataProvider
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 ModuleDataProvider.
11 12 13 14 |
# File 'lib/puppet/pops/lookup/module_data_provider.rb', line 11 def initialize(module_name, config = nil) super(config) @module_name = module_name end |
Instance Attribute Details
#module_name ⇒ Object (readonly)
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.
9 10 11 |
# File 'lib/puppet/pops/lookup/module_data_provider.rb', line 9 def module_name @module_name end |
Instance Method Details
#key_lookup_in_default(key, lookup_invocation, merge) ⇒ Object
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.
Performs a lookup using a module default hierarchy with an endless recursion check.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/puppet/pops/lookup/module_data_provider.rb', line 26 def key_lookup_in_default(key, lookup_invocation, merge) dps = config(lookup_invocation).configured_data_providers(lookup_invocation, self, true) if dps.empty? lookup_invocation.report_not_found(key) throw :no_such_key end merge_strategy = MergeStrategy.strategy(merge) lookup_invocation.check(key.to_s) do lookup_invocation.with(:data_provider, self) do merge_strategy.lookup(dps, lookup_invocation) do |data_provider| data_provider.unchecked_key_lookup(key, lookup_invocation, merge_strategy) end end end end |
#place ⇒ Object
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.
16 17 18 |
# File 'lib/puppet/pops/lookup/module_data_provider.rb', line 16 def place 'Module' end |
#validate_data_hash(data_hash) ⇒ Hash
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.
Asserts that all keys in the given data_hash are prefixed with the configured module_name. Removes entries that does not follow the convention and logs a warning.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/puppet/pops/lookup/module_data_provider.rb', line 47 def validate_data_hash(data_hash) super module_prefix = "#{module_name}::" data_hash_to_return = {} data_hash.keys.each do |k| if k == LOOKUP_OPTIONS || k.start_with?(module_prefix) data_hash_to_return[k] = data_hash[k] else msg = "#{yield} must use keys qualified with the name of the module" Puppet.warning("Module '#{module_name}': #{msg}; got #{k}") end end data_hash_to_return end |