Module: Puppet::Pops::Lookup::DataProvider Private
- 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
- .ensure_types_initialized ⇒ Object private
- .key_type ⇒ 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.
- #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_provider, data_hash) ⇒ Hash{String=>Object}
private
Asserts that data_hash is a hash.
-
#validate_data_value(data_provider, value) ⇒ Object
private
Asserts that data_value is of valid type.
Class Method Details
.ensure_types_initialized ⇒ 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 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 15 def self.ensure_types_initialized if @key_type.nil? (@key_type, @value_type) = Pcore::register_aliases( # The Pcore type for all keys and subkeys in a data hash. 'Puppet::LookupKey' => 'Variant[String,Numeric]', # The Pcore type for all values and sub-values in a data hash. The # type is self-recursive to enforce the same constraint on values contained # in arrays and hashes 'Puppet::LookupValue' => " Variant[\n Scalar,\n Undef,\n Sensitive,\n Type,\n Hash[Puppet::LookupKey, Puppet::LookupValue],\n Array[Puppet::LookupValue]\n ]\n PUPPET\n )\n end\nend\n" |
.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 8 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 5 def self.key_type ensure_types_initialized @key_type 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.
10 11 12 13 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 10 def self.value_type ensure_types_initialized @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.
44 45 46 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 44 def key_lookup(key, lookup_invocation, merge) lookup_invocation.check(key.to_s) { unchecked_key_lookup(key, lookup_invocation, merge) } 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.
48 49 50 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 48 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.
64 65 66 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 64 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.
69 70 71 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 69 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.
59 60 61 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 59 def unchecked_key_lookup(key, lookup_invocation, merge) raise NotImplementedError, "Subclass of #{DataProvider.name} must implement 'unchecked_lookup' method" end |
#validate_data_hash(data_provider, data_hash) ⇒ 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.
78 79 80 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 78 def validate_data_hash(data_provider, data_hash) Types::TypeAsserter.assert_instance_of(nil, Types::PHashType::DEFAULT, data_hash) { "Value returned from #{data_provider.name}" } end |
#validate_data_value(data_provider, value) ⇒ 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.
87 88 89 90 |
# File 'lib/puppet/pops/lookup/data_provider.rb', line 87 def validate_data_value(data_provider, value) # The DataProvider.value_type is self recursive so further recursive check of collections is needed here Types::TypeAsserter.assert_instance_of(nil, DataProvider.value_type, value) { "Value returned from #{data_provider.name}" } end |