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.
7 8 9 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 7 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.
15 16 17 18 19 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 15 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.
11 12 13 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 11 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.
27 28 29 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 27 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.
38 39 40 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 38 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.
42 43 44 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 42 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.
58 59 60 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 58 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.
63 64 65 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 63 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.
53 54 55 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 53 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
76 77 78 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 76 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
84 85 86 87 88 89 90 91 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 84 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.
68 69 70 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 68 def value_is_validated? false end |