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

Instance Method Summary collapse

Methods included from DataProvider

ensure_types_initialized, #key_lookup, key_type, #lookup, #unchecked_key_lookup, #validate_data_entry, #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.



13
14
15
16
17
18
19
20
# File 'lib/puppet/pops/lookup/function_provider.rb', line 13

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_name ⇒ Object (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.



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

def function_name
  @function_name
end

#locations ⇒ Object (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.



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

def locations
  @locations
end

#parent_data_provider ⇒ Object (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.



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

def parent_data_provider
  @parent_data_provider
end

Instance Method Details

#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:



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

def function_context(lookup_invocation, location)
  scope = lookup_invocation.scope
  compiler = scope.compiler
  @contexts[location] ||= FunctionContext.new(compiler.environment.name, module_name, function(scope))
end

#module_name ⇒ 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.



29
30
31
# File 'lib/puppet/pops/lookup/function_provider.rb', line 29

def module_name
  @parent_data_provider.module_name
end

#name ⇒ 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.



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

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:



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/puppet/pops/lookup/function_provider.rb', line 45

def options(location = nil)
  case location
  when nil
    @options
  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_s ⇒ 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 to_s
  name
end