Class: Puppet::Context::EmptyStack Private

Inherits:
Object
  • Object
show all
Defined in:
lib/puppet/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.

Base case for Puppet::Context::Stack.

Instance Method Summary collapse

Instance Method Details

#bindingsObject

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.

Return the bindings table, which is always empty here



135
136
137
# File 'lib/puppet/context.rb', line 135

def bindings
  {}
end

#lookup(name, &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.

Lookup a binding. Since there are none in EmptyStack, this always raises an exception unless a block is passed, in which case the block is called and its return value is used.



108
109
110
111
112
113
114
# File 'lib/puppet/context.rb', line 108

def lookup(name, &block)
  if block
    block.call
  else
    raise UndefinedBindingError, _("Unable to lookup '%{name}'") % { name: name }
  end
end

#popObject

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.

Base case of #pop always raises an error since this is the bottom

Raises:



119
120
121
122
# File 'lib/puppet/context.rb', line 119

def pop
  raise(StackUnderflow,
        _('Attempted to pop, but already at root of the context stack.'))
end

#push(overrides, description = '') ⇒ 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.

Push bindings onto the stack by creating a new Stack object with ‘self` as the parent



128
129
130
# File 'lib/puppet/context.rb', line 128

def push(overrides, description = '')
  Puppet::Context::Stack.new(self, overrides, description)
end