Sha256: 1b83513786143cc957a6f5df4a80c11404d8d6d233371b034486a4ca6ba2b395
Contents?: true
Size: 882 Bytes
Versions: 170
Compression:
Stored size: 882 Bytes
Contents
require 'puppet/parser/ast/branch' class Puppet::Parser::AST # A basic 'if/elsif/else' statement. class IfStatement < AST::Branch associates_doc attr_accessor :test, :else, :statements def each [@test,@else,@statements].each { |child| yield child } end # Short-curcuit evaluation. If we're true, evaluate our statements, # else if there's an 'else' setting, evaluate it. # the first option that matches. def evaluate(scope) level = scope.ephemeral_level value = @test.safeevaluate(scope) # let's emulate a new scope for each branches begin if Puppet::Parser::Scope.true?(value) return @statements.safeevaluate(scope) else return defined?(@else) ? @else.safeevaluate(scope) : nil end ensure scope.unset_ephemeral_var(level) end end end end
Version data entries
170 entries across 170 versions & 5 rubygems