Module: Puppet::Plugins::DataProviders::DataProvider
- Included in:
- EnvironmentDataProvider, ModuleDataProvider, PathBasedDataProvider
- Defined in:
- lib/puppet/plugins/data_providers/data_provider.rb
Overview
Instance Method Summary collapse
-
#data_key(key, lookup_invocation) ⇒ String?
Obtain an optional key to use when retrieving the data.
-
#lookup(name, lookup_invocation, merge) ⇒ Object
Performs a lookup with an endless recursion check.
- #name ⇒ Object
-
#post_process(value, lookup_invocation) ⇒ Object
Perform optional post processing of found value.
-
#unchecked_lookup(key, lookup_invocation, merge) ⇒ Object
Performs a lookup with the assumption that a recursive check has been made.
- #validate_data(data, data_key) ⇒ Object
Instance Method Details
#data_key(key, lookup_invocation) ⇒ String?
Obtain an optional key to use when retrieving the data.
72 73 74 |
# File 'lib/puppet/plugins/data_providers/data_provider.rb', line 72 def data_key(key, lookup_invocation) nil end |
#lookup(name, lookup_invocation, merge) ⇒ Object
Performs a lookup with an endless recursion check.
10 11 12 |
# File 'lib/puppet/plugins/data_providers/data_provider.rb', line 10 def lookup(name, lookup_invocation, merge) lookup_invocation.check(name) { unchecked_lookup(name, lookup_invocation, merge) } end |
#name ⇒ Object
88 89 90 91 |
# File 'lib/puppet/plugins/data_providers/data_provider.rb', line 88 def name cname = self.class.name cname[cname.rindex(':')+1..-1] end |
#post_process(value, lookup_invocation) ⇒ Object
Perform optional post processing of found value. This hook is used by the hiera style providers to perform interpolation. The default method simply returns the given value.
42 43 44 |
# File 'lib/puppet/plugins/data_providers/data_provider.rb', line 42 def post_process(value, lookup_invocation) value end |
#unchecked_lookup(key, lookup_invocation, merge) ⇒ Object
Performs a lookup with the assumption that a recursive check has been made.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/puppet/plugins/data_providers/data_provider.rb', line 21 def unchecked_lookup(key, lookup_invocation, merge) lookup_invocation.with(:data_provider, self) do hash = data(data_key(key, lookup_invocation), lookup_invocation) value = hash[key] if value || hash.include?(key) lookup_invocation.report_found(key, post_process(value, lookup_invocation)) else lookup_invocation.report_not_found(key) throw :no_such_key end end end |
#validate_data(data, data_key) ⇒ Object
93 94 95 |
# File 'lib/puppet/plugins/data_providers/data_provider.rb', line 93 def validate_data(data, data_key) data end |