Class: Puppet::Parser::AST::ASTHash

Inherits:
Leaf show all
Includes:
Enumerable
Defined in:
lib/vendor/puppet/parser/ast/asthash.rb

Constant Summary

Constants inherited from Puppet::Parser::AST

AST

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Instance Attribute Summary

Attributes inherited from Leaf

#type, #value

Attributes inherited from Puppet::Parser::AST

#file, #line, #parent, #scope

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods inherited from Leaf

#match

Methods inherited from Puppet::Parser::AST

associates_doc, #evaluate_match, #inspect, #parsefail, #parsewrap, #safeevaluate, settor?, #use_docs

Methods included from Util::Docs

#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub

Methods included from Util::MethodHelper

#requiredopts, #set_options, #symbolize_options

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail

Constructor Details

#initialize(args) ⇒ ASTHash

Returns a new instance of ASTHash.



32
33
34
35
# File 'lib/vendor/puppet/parser/ast/asthash.rb', line 32

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

Instance Method Details

#evaluate(scope) ⇒ Object

Evaluate our children.



8
9
10
11
12
13
14
15
16
17
# File 'lib/vendor/puppet/parser/ast/asthash.rb', line 8

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

#merge(hash) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/vendor/puppet/parser/ast/asthash.rb', line 19

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

#to_sObject



28
29
30
# File 'lib/vendor/puppet/parser/ast/asthash.rb', line 28

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