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

Constants included from Util::Docs

Util::Docs::HEADER_LEVELS

Instance Attribute Summary collapse

Attributes inherited from Puppet::Parser::AST

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

Attributes included from Util::Docs

#doc, #nodoc

Instance Method Summary collapse

Methods inherited from Puppet::Parser::AST

associates_doc, #evaluate, #evaluate_match, #inspect, #parsefail, #parsewrap, #safeevaluate, #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(names, context = {}, &ruby_code) ⇒ Node

Returns a new instance of Node.

Raises:

  • (ArgumentError)


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

def initialize(names, context = {}, &ruby_code)
  raise ArgumentError, "names should be an array" unless names.is_a? Array
  if context[:parent]
    msg = "Deprecation notice: Node inheritance is not supported in Puppet >= 4.0.0. See http://links.puppetlabs.com/puppet-node-inheritance-deprecation"
    Puppet.puppet_deprecation_warning(msg, :key => "node-inheritance-#{names.join}", :file => context[:file], :line => context[:line])
  end

  @names = names
  @context = context
  @ruby_code = ruby_code
end

Instance Attribute Details

#contextObject



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

def context
  @context
end

#namesObject



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

def names
  @names
end

Instance Method Details

#instantiate(modname) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/puppet/parser/ast/node.rb', line 18

def instantiate(modname)
  @names.collect do |name|
    new_node = Puppet::Resource::Type.new(:node, name, @context.merge(:module_name => modname))
    new_node.ruby_code = @ruby_code if @ruby_code
    new_node
  end
end