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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

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.



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

def environment_name
  @environment_context.environment_name
end