Module: Puppet::Pops::Lookup::DataProvider Private
- Included in:
- ConfiguredDataProvider, FunctionProvider
- Defined in:
- lib/puppet/pops/lookup/data_provider.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .key_type ⇒ Object private
- .register_types(loader) ⇒ Object private
- .value_type ⇒ Object private
Instance Method Summary collapse
-
#key_lookup(key, lookup_invocation, merge) ⇒ Object
private
Performs a lookup with an endless recursion check.
-
#key_lookup_in_default(key, lookup_invocation, merge) ⇒ Object
private
Performs a lookup using a module default hierarchy with an endless recursion check.
- #lookup(key, lookup_invocation, merge) ⇒ Object private
-
#module_name ⇒ String?
private
The name of the module that this provider belongs to nor ‘nil` if it doesn’t belong to a module.
-
#name ⇒ String
private
The name of the this data provider.
-
#unchecked_key_lookup(key, lookup_invocation, merge) ⇒ Object
private
Performs a lookup with the assumption that a recursive check has been made.
-
#validate_data_hash(data_hash, &block) ⇒ Hash{String=>Object}
private
Asserts that data_hash is a hash.
-
#validate_data_value(value, &block) ⇒ Object
private
Asserts that data_value is of valid type.
- #value_is_validated? ⇒ Boolean private
Class Method Details
.key_type ⇒ 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.
5 6 7 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 5 def self.key_type @key_type end |
.register_types(loader) ⇒ 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.
13 14 15 16 17 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 13 def self.register_types(loader) tp = Types::TypeParser.singleton @key_type = tp.parse('RichDataKey', loader) @value_type = tp.parse('RichData', loader) end |
.value_type ⇒ 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.
9 10 11 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 9 def self.value_type @value_type end |
Instance Method Details
#key_lookup(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 with an endless recursion check.
25 26 27 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 25 def key_lookup(key, lookup_invocation, merge) lookup_invocation.check(key.to_s) { unchecked_key_lookup(key, lookup_invocation, merge) } end |
#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. All providers except the ‘ModuleDataProvider` will throw `:no_such_key` if this method is called.
36 37 38 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 36 def key_lookup_in_default(key, lookup_invocation, merge) throw :no_such_key end |
#lookup(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.
40 41 42 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 40 def lookup(key, lookup_invocation, merge) lookup_invocation.check(key.to_s) { unchecked_key_lookup(key, lookup_invocation, merge) } end |
#module_name ⇒ String?
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 the name of the module that this provider belongs to nor ‘nil` if it doesn’t belong to a module.
56 57 58 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 56 def module_name nil end |
#name ⇒ String
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 the name of the this data provider.
61 62 63 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 61 def name raise NotImplementedError, "Subclass of #{DataProvider.name} must implement 'name' method" end |
#unchecked_key_lookup(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 with the assumption that a recursive check has been made.
51 52 53 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 51 def unchecked_key_lookup(key, lookup_invocation, merge) raise NotImplementedError, "Subclass of #{DataProvider.name} must implement 'unchecked_lookup' method" end |
#validate_data_hash(data_hash, &block) ⇒ Hash{String=>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.
Asserts that data_hash is a hash. Will yield to obtain origin of value in case an error is produced
74 75 76 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 74 def validate_data_hash(data_hash, &block) Types::TypeAsserter.assert_instance_of(nil, Types::PHashType::DEFAULT, data_hash, &block) end |
#validate_data_value(value, &block) ⇒ 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.
Asserts that data_value is of valid type. Will yield to obtain origin of value in case an error is produced
82 83 84 85 86 87 88 89 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 82 def validate_data_value(value, &block) # The DataProvider.value_type is self recursive so further recursive check of collections is needed here unless value_is_validated? || DataProvider.value_type.instance?(value) actual_type = Types::TypeCalculator.singleton.infer(value) raise Types::TypeAssertionError.new("#{yield} has wrong type, expects Puppet::LookupValue, got #{actual_type}", DataProvider.value_type, actual_type) end value end |
#value_is_validated? ⇒ Boolean
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.
66 67 68 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 66 def value_is_validated? false end |