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.

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_name, 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



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

def initialize(environment_name, module_name, function)
  @data_hash = nil
  @cache = {}
  @environment_name = environment_name
  @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



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

def data_hash
  @data_hash
end

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



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

def environment_name
  @environment_name
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



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

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



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

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



22
23
24
# File 'lib/puppet/pops/lookup/context.rb', line 22

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



26
27
28
29
# File 'lib/puppet/pops/lookup/context.rb', line 26

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



31
32
33
# File 'lib/puppet/pops/lookup/context.rb', line 31

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



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/puppet/pops/lookup/context.rb', line 39

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_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



35
36
37
# File 'lib/puppet/pops/lookup/context.rb', line 35

def cached_value(key)
  @cache[key]
end