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: //usr/lib/ruby/site_ruby/1.8/puppet/parser/ast/asthash.rb
require 'puppet/parser/ast/leaf'

class Puppet::Parser::AST
  class ASTHash < Leaf
    include Enumerable

    # Evaluate our children.
    def evaluate(scope)
      items = {}

      @value.each_pair do |k,v|
        key = k.respond_to?(:safeevaluate) ? k.safeevaluate(scope) : k
        items.merge!({ key => v.safeevaluate(scope) })
      end

      items
    end

    def merge(hash)
      case hash
      when ASTHash
        @value = @value.merge(hash.value)
      when Hash
        @value = @value.merge(hash)
      end
    end

    def to_s
      "{" + @value.collect { |v| v.collect { |a| a.to_s }.join(' => ') }.join(', ') + "}"
    end

    def initialize(args)
      super(args)
      @value ||= {}
    end
  end
end