HEX
Server: Apache
System: Linux sg241.singhost.net 2.6.32-896.16.1.lve1.4.51.el6.x86_64 #1 SMP Wed Jan 17 13:19:23 EST 2018 x86_64
User: honghock (909)
PHP: 8.0.30
Disabled: passthru,system,shell_exec,show_source,exec,popen,proc_open
Upload Files
File: //proc/self/root/usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/vardef.rb
require 'puppet/parser/ast/branch'

class Puppet::Parser::AST
  # Define a variable.  Stores the value in the current scope.
  class VarDef < AST::Branch

    associates_doc

    attr_accessor :name, :value, :append

    # Look up our name and value, and store them appropriately.  The
    # lexer strips off the syntax stuff like '$'.
    def evaluate(scope)
      value = @value.safeevaluate(scope)
      if name.is_a?(HashOrArrayAccess)
        name.assign(scope, value)
      else
        name = @name.safeevaluate(scope)

        parsewrap do
          scope.setvar(name,value, :file => file, :line => line, :append => @append)
        end
      end
      if @append
        # Produce resulting value from append operation
        scope[name]
      else
        # Produce assigned value
        value
      end
    end

    def each
      [@name,@value].each { |child| yield child }
    end
  end

end