Class: Puppet::Pops::Lookup::FunctionProvider Private

Inherits:
Object
  • Object
show all
Includes:
DataProvider
Defined in:
lib/puppet/pops/lookup/function_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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DataProvider

#key_lookup, #key_lookup_in_default, key_type, #lookup, register_types, #unchecked_key_lookup, #validate_data_hash, #validate_data_value, value_type

Constructor Details

#initialize(name, parent_data_provider, function_name, options, locations) ⇒ FunctionProvider

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 FunctionProvider.



23
24
25
26
27
28
29
30
# File 'lib/puppet/pops/lookup/function_provider.rb', line 23

def initialize(name, parent_data_provider, function_name, options, locations)
  @name = name
  @parent_data_provider = parent_data_provider
  @function_name = function_name
  @options = options
  @locations = locations || [nil]
  @contexts = {}
end

Instance Attribute Details

#function_nameObject (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.



12
13
14
# File 'lib/puppet/pops/lookup/function_provider.rb', line 12

def function_name
  @function_name
end

#locationsObject (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.



12
13
14
# File 'lib/puppet/pops/lookup/function_provider.rb', line 12

def locations
  @locations
end

#parent_data_providerObject (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.



12
13
14
# File 'lib/puppet/pops/lookup/function_provider.rb', line 12

def parent_data_provider
  @parent_data_provider
end

Class Method Details

.trusted_return_typeType

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 type that all the return type of all functions must be assignable to. For ‘lookup_key` and `data_dig`, that will be the `Puppet::LookupValue` type. For `data_hash` it will be a Hash`

Returns:

  • (Type)

    the trusted return type



19
20
21
# File 'lib/puppet/pops/lookup/function_provider.rb', line 19

def self.trusted_return_type
  DataProvider.value_type
end

Instance Method Details

#create_function_context(lookup_invocation) ⇒ 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.



37
38
39
# File 'lib/puppet/pops/lookup/function_provider.rb', line 37

def create_function_context(lookup_invocation)
  FunctionContext.new(EnvironmentContext.adapt(lookup_invocation.scope.compiler.environment), module_name, function(lookup_invocation))
end

#full_nameObject

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.



49
50
51
# File 'lib/puppet/pops/lookup/function_provider.rb', line 49

def full_name
  "#{self.class::TAG} function '#{@function_name}'"
end

#function_context(lookup_invocation, location) ⇒ FunctionContext

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 function context associated with this provider.

Returns:



33
34
35
# File 'lib/puppet/pops/lookup/function_provider.rb', line 33

def function_context(lookup_invocation, location)
  @contexts[location] ||= create_function_context(lookup_invocation)
end

#module_nameObject

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.



41
42
43
# File 'lib/puppet/pops/lookup/function_provider.rb', line 41

def module_name
  @parent_data_provider.module_name
end

#nameObject

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.



45
46
47
# File 'lib/puppet/pops/lookup/function_provider.rb', line 45

def name
  "Hierarchy entry \"#{@name}\""
end

#options(location = nil) ⇒ 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.

Obtains the options to send to the function, optionally merged with a ‘path’ or ‘uri’ option

Parameters:

  • location (Pathname, URI) (defaults to: nil)

    The location to add to the options

Returns:

  • (Hash{String => Object})

    The options hash



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/puppet/pops/lookup/function_provider.rb', line 61

def options(location = nil)
  location = location.location unless location.nil?
  case location
  when Pathname
    @options.merge(HieraConfig::KEY_PATH => location.to_s)
  when URI
    @options.merge(HieraConfig::KEY_URI => location.to_s)
  else
    @options
  end
end

#to_sObject

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.



53
54
55
# File 'lib/puppet/pops/lookup/function_provider.rb', line 53

def to_s
  name
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.

Returns:

  • (Boolean)


73
74
75
# File 'lib/puppet/pops/lookup/function_provider.rb', line 73

def value_is_validated?
  @value_is_validated
end