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, callee_name, 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, callee_name, 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.
223 224 225 226 227 228 |
# File 'lib/puppet/parser/scope.rb', line 223 def initialize(parent, callee_name, param_names) super(parent) @callee_name = callee_name @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.
230 231 232 233 234 235 |
# File 'lib/puppet/parser/scope.rb', line 230 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.
237 238 239 240 241 |
# File 'lib/puppet/parser/scope.rb', line 237 def []=(name, value) raise Puppet::Error, _("Attempt to assign variable %{name} when evaluating parameters") % { name: name } 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.
255 256 257 258 259 260 261 262 263 |
# File 'lib/puppet/parser/scope.rb', line 255 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.
243 244 245 |
# File 'lib/puppet/parser/scope.rb', line 243 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.
205 206 207 208 209 210 211 212 213 |
# File 'lib/puppet/parser/scope.rb', line 205 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 parameter_reference_failure(name, 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.
195 196 197 198 199 200 201 202 203 |
# File 'lib/puppet/parser/scope.rb', line 195 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 parameter_reference_failure(name, 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.
247 248 249 |
# File 'lib/puppet/parser/scope.rb', line 247 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.
251 252 253 |
# File 'lib/puppet/parser/scope.rb', line 251 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.
265 266 267 |
# File 'lib/puppet/parser/scope.rb', line 265 def to_hash Hash[@params.select {|_, access| access.assigned? }.map { |name, access| [name, access.value] }] end |