Class: Puppet::Parser::AST::ASTHash
- Inherits:
-
Leaf
- Object
- Puppet::Parser::AST
- Leaf
- Puppet::Parser::AST::ASTHash
- Includes:
- Enumerable
- Defined in:
- lib/vendor/puppet/parser/ast/asthash.rb
Constant Summary
Constants inherited from Puppet::Parser::AST
Constants included from Util::Docs
Instance Attribute Summary
Attributes inherited from Leaf
Attributes inherited from Puppet::Parser::AST
Attributes included from Util::Docs
Instance Method Summary collapse
-
#evaluate(scope) ⇒ Object
Evaluate our children.
-
#initialize(args) ⇒ ASTHash
constructor
A new instance of ASTHash.
- #merge(hash) ⇒ Object
- #to_s ⇒ Object
Methods inherited from Leaf
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_s ⇒ Object
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 |