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

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


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

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.


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

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.


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

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.


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

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.


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

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.


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

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.


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

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.


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

def cached_entries(&block)
  if block_given?
    enumerator = @cache.each_pair
    @cache.size.times do
      if block.arity == 2
        yield(*enumerator.next)
      else
        yield(enumerator.next)
      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.


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.


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

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.


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

def environment_name
  @environment_context.environment_name
end