Class: Puppet::Pops::Lookup::FunctionContext Private

Inherits:
Object
  • Object
show all
Includes:
Interpolation
Defined in:
lib/puppet/pops/lookup/context.rb

Overview

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.

A FunctionContext is created for each unique hierarchy entry and adapted to the Compiler (and hence shares the compiler’s life-cycle).

API:

  • private

Constant Summary

Constants included from SubLookup

SubLookup::SPECIAL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Interpolation

#interpolate

Methods included from SubLookup

#split_key, #sub_lookup

Constructor Details

#initialize(environment_context, module_name, function) ⇒ 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 a new instance of FunctionContext.

API:

  • private



69
70
71
72
73
74
75
# File 'lib/puppet/pops/lookup/context.rb', line 69

def initialize(environment_context, module_name, function)
  @data_hash = nil
  @cache = {}
  @environment_context = environment_context
  @module_name = module_name
  @function = function
end

Instance Attribute Details

#data_hashObject

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.

API:

  • private



67
68
69
# File 'lib/puppet/pops/lookup/context.rb', line 67

def data_hash
  @data_hash
end

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

API:

  • private



66
67
68
# File 'lib/puppet/pops/lookup/context.rb', line 66

def function
  @function
end

#module_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.

API:

  • private



66
67
68
# File 'lib/puppet/pops/lookup/context.rb', line 66

def module_name
  @module_name
end

Instance Method Details

#cache(key, 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.

API:

  • private



77
78
79
# File 'lib/puppet/pops/lookup/context.rb', line 77

def cache(key, value)
  @cache[key] = value
end

#cache_all(hash) ⇒ 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.

API:

  • private



81
82
83
84
# File 'lib/puppet/pops/lookup/context.rb', line 81

def cache_all(hash)
  @cache.merge!(hash)
  nil
end

#cache_has_key(key) ⇒ 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.

API:

  • private



86
87
88
# File 'lib/puppet/pops/lookup/context.rb', line 86

def cache_has_key(key)
  @cache.include?(key)
end

#cached_entries(&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.

API:

  • private



94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/puppet/pops/lookup/context.rb', line 94

def cached_entries(&block)
  if block_given?
    @cache.each_pair do |pair|
      if block.arity == 2
        yield(*pair)
      else
        yield(pair)
      end
    end
    nil
  else
    Types::Iterable.on(@cache)
  end
end

#cached_file_data(path, &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.

API:

  • private



109
110
111
# File 'lib/puppet/pops/lookup/context.rb', line 109

def cached_file_data(path, &block)
  @environment_context.cached_file_data(path, &block)
end

#cached_value(key) ⇒ 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.

API:

  • private



90
91
92
# File 'lib/puppet/pops/lookup/context.rb', line 90

def cached_value(key)
  @cache[key]
end

#environment_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.

API:

  • private



113
114
115
# File 'lib/puppet/pops/lookup/context.rb', line 113

def environment_name
  @environment_context.environment_name
end