Class: Puppet::Parser::AST::Node

Inherits:
TopLevelConstruct show all
Defined in:
lib/puppet/parser/ast/node.rb

Constant Summary

Constants inherited from Puppet::Parser::AST

AST

Instance Attribute Summary collapse

Attributes inherited from Puppet::Parser::AST

#file, #line, #parent, #pos, #scope

Instance Method Summary collapse

Methods inherited from Puppet::Parser::AST

#evaluate, #inspect, #safeevaluate

Methods included from Util::Errors

#adderrorcontext, #devfail, #error_context, error_location, error_location_with_space, error_location_with_unknowns, #exceptwrap, #fail

Constructor Details

#initialize(names, context = {}) ⇒ Node

Returns a new instance of Node.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
14
# File 'lib/puppet/parser/ast/node.rb', line 6

def initialize(names, context = {})
  raise ArgumentError, _("names should be an array") unless names.is_a? Array
  if context[:parent]
    raise Puppet::DevError, _("Node inheritance is removed in Puppet 4.0.0. See http://links.puppet.com/puppet-node-inheritance-deprecation")
  end

  @names = names
  @context = context
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



4
5
6
# File 'lib/puppet/parser/ast/node.rb', line 4

def context
  @context
end

#namesObject

Returns the value of attribute names.



4
5
6
# File 'lib/puppet/parser/ast/node.rb', line 4

def names
  @names
end

Instance Method Details

#instantiate(modname) ⇒ Object



16
17
18
# File 'lib/puppet/parser/ast/node.rb', line 16

def instantiate(modname)
  @names.map { |name| Puppet::Resource::Type.new(:node, name, @context.merge(:module_name => modname)) }
end