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)

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

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


2
3
4
# File 'lib/puppet/parser/ast/node.rb', line 2

def context
  @context
end

#namesObject

Returns the value of attribute names


2
3
4
# File 'lib/puppet/parser/ast/node.rb', line 2

def names
  @names
end

Instance Method Details

#instantiate(modname) ⇒ Object


14
15
16
# File 'lib/puppet/parser/ast/node.rb', line 14

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