diff options
Diffstat (limited to 'lib/puppet/parser/ast/compdef.rb')
-rw-r--r-- | lib/puppet/parser/ast/compdef.rb | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/puppet/parser/ast/compdef.rb b/lib/puppet/parser/ast/compdef.rb index 696e178e1..b6cd6491f 100644 --- a/lib/puppet/parser/ast/compdef.rb +++ b/lib/puppet/parser/ast/compdef.rb @@ -9,7 +9,15 @@ class Puppet::Parser::AST # encounter an error if the component is instantiated more than # once. class CompDef < AST::Branch - attr_accessor :type, :args, :code, :keyword, :scope, :parentclass + attr_accessor :type, :args, :code, :scope, :parentclass + attr_writer :keyword + + @keyword = "define" + + class << self + attr_reader :keyword + end + def self.genclass AST::Component @@ -33,6 +41,7 @@ class Puppet::Parser::AST arghash[:parentclass] = @parentclass.safeevaluate(:scope => scope) end + begin comp = self.class.genclass.new(arghash) comp.keyword = self.keyword @@ -53,9 +62,6 @@ class Puppet::Parser::AST def initialize(hash) @parentclass = nil @args = nil - - # Set a default keyword - @keyword = "define" super #if @parentclass @@ -66,6 +72,14 @@ class Puppet::Parser::AST #Puppet.debug "Defining type %s" % @type.value end + def keyword + if defined? @keyword + @keyword + else + self.class.keyword + end + end + def tree(indent = 0) return [ @type.tree(indent + 1), |