Class: Puppet::Parser::AST::Hostclass

Inherits:
TopLevelConstruct show all
Defined in:
lib/puppet/parser/ast/hostclass.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(name, context = {}) ⇒ Hostclass

Returns a new instance of Hostclass.



8
9
10
11
# File 'lib/puppet/parser/ast/hostclass.rb', line 8

def initialize(name, context = {})
  @context = context
  @name = name
end

Instance Attribute Details

#contextObject

Returns the value of attribute context.



6
7
8
# File 'lib/puppet/parser/ast/hostclass.rb', line 6

def context
  @context
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/puppet/parser/ast/hostclass.rb', line 6

def name
  @name
end

Instance Method Details

#codeObject



26
27
28
# File 'lib/puppet/parser/ast/hostclass.rb', line 26

def code
  @context[:code]
end

#instantiate(modname) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/puppet/parser/ast/hostclass.rb', line 13

def instantiate(modname)
  new_class = Puppet::Resource::Type.new(:hostclass, @name, @context.merge(:module_name => modname))
  all_types = [new_class]
  if code
    code.each do |nested_ast_node|
      if nested_ast_node.respond_to? :instantiate
        all_types += nested_ast_node.instantiate(modname)
      end
    end
  end
  all_types
end