Class: Puppet::Parser::Scope::ParameterScope Private
- Defined in:
- lib/puppet/parser/scope.rb
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.
Defined Under Namespace
Classes: Access
Instance Attribute Summary
Attributes inherited from Ephemeral
Instance Method Summary collapse
- #[](name) ⇒ Object private
- #[]=(name, value) ⇒ Object private
- #as_read_only ⇒ Object private
- #bound?(name) ⇒ Boolean private
- #evaluate(name, expression, scope, evaluator) ⇒ Object private
-
#evaluate3x(name, expression, scope) ⇒ Object
private
A parameter default must be evaluated using a special scope.
- #include?(name) ⇒ Boolean private
-
#initialize(parent, param_names) ⇒ ParameterScope
constructor
private
A new instance of ParameterScope.
- #is_local_scope? ⇒ Boolean private
- #to_hash ⇒ Object private
Methods inherited from Ephemeral
Constructor Details
#initialize(parent, param_names) ⇒ ParameterScope
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 ParameterScope.
218 219 220 221 222 |
# File 'lib/puppet/parser/scope.rb', line 218 def initialize(parent, param_names) super(parent) @params = {} param_names.each { |name| @params[name] = Access.new } end |
Instance Method Details
#[](name) ⇒ 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.
224 225 226 227 228 229 |
# File 'lib/puppet/parser/scope.rb', line 224 def [](name) access = @params[name] return super if access.nil? throw(:unevaluated_parameter, name) unless access.assigned? access.value end |
#[]=(name, 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.
231 232 233 234 235 |
# File 'lib/puppet/parser/scope.rb', line 231 def []=(name, value) raise Puppet::Error, "Attempt to assign variable #{name} when evaluating parameters" if @read_only @params[name] ||= Access.new @params[name].value = value end |
#as_read_only ⇒ 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.
249 250 251 252 253 254 255 256 257 |
# File 'lib/puppet/parser/scope.rb', line 249 def as_read_only read_only = @read_only @read_only = true begin yield ensure @read_only = read_only end end |
#bound?(name) ⇒ Boolean
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.
237 238 239 |
# File 'lib/puppet/parser/scope.rb', line 237 def bound?(name) @params.include?(name) end |
#evaluate(name, expression, scope, evaluator) ⇒ 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.
208 209 210 211 212 213 214 215 216 |
# File 'lib/puppet/parser/scope.rb', line 208 def evaluate(name, expression, scope, evaluator) scope.with_guarded_scope do bad = catch(:unevaluated_parameter) do scope.new_match_scope(nil) return as_read_only { evaluator.evaluate(expression, scope) } end raise Puppet::Error, "default expression for $#{name} tries to illegally access not yet evaluated $#{bad}" end end |
#evaluate3x(name, expression, scope) ⇒ 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.
A parameter default must be evaluated using a special scope. The scope that is given to this method must have a ‘ParameterScope` as its last ephemeral scope. This method will then push a `MatchScope` while the given `expression` is evaluated. The method will catch any throw of `:unevaluated_parameter` and produce an error saying that the evaluated parameter X tries to access the unevaluated parameter Y.
198 199 200 201 202 203 204 205 206 |
# File 'lib/puppet/parser/scope.rb', line 198 def evaluate3x(name, expression, scope) scope.with_guarded_scope do bad = catch(:unevaluated_parameter) do scope.new_match_scope(nil) return as_read_only { expression.safeevaluate(scope) } end raise Puppet::Error, "default expression for $#{name} tries to illegally access not yet evaluated $#{bad}" end end |
#include?(name) ⇒ Boolean
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.
241 242 243 |
# File 'lib/puppet/parser/scope.rb', line 241 def include?(name) @params.include?(name) || super end |
#is_local_scope? ⇒ Boolean
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.
245 246 247 |
# File 'lib/puppet/parser/scope.rb', line 245 def is_local_scope? true end |
#to_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.
259 260 261 |
# File 'lib/puppet/parser/scope.rb', line 259 def to_hash Hash[@params.select {|_, access| access.assigned? }.map { |name, access| [name, access.value] }] end |