diff options
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/ast/component.rb | 16 | ||||
-rw-r--r-- | lib/puppet/parser/ast/hostclass.rb | 16 | ||||
-rw-r--r-- | lib/puppet/parser/ast/node.rb | 12 |
3 files changed, 19 insertions, 25 deletions
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb index 6a309ac8c..a3d1fb026 100644 --- a/lib/puppet/parser/ast/component.rb +++ b/lib/puppet/parser/ast/component.rb @@ -21,6 +21,8 @@ class Puppet::Parser::AST # These are retrieved when looking up the superclass attr_accessor :name + attr_reader :parentclass + def child_of?(klass) false end @@ -132,10 +134,8 @@ class Puppet::Parser::AST end end - def parentclass - parentobj do |name| - @interp.findclass(namespace, name) - end + def find_parentclass + @interp.findclass(namespace, parentclass) end # Set our parent class, with a little check to avoid some potential @@ -152,8 +152,8 @@ class Puppet::Parser::AST def parentobj if @parentclass # Cache our result, since it should never change. - unless @parentclass.is_a?(AST::HostClass) - unless tmp = yield(@parentclass) + unless defined?(@parentobj) + unless tmp = find_parentclass parsefail "Could not find %s %s" % [self.class.name, @parentclass] end @@ -161,9 +161,9 @@ class Puppet::Parser::AST parsefail "Parent classes must have dissimilar names" end - @parentclass = tmp + @parentobj = tmp end - @parentclass + @parentobj else nil end diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index 526265c1c..5416c1071 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -12,10 +12,10 @@ class Puppet::Parser::AST def child_of?(klass) return false unless self.parentclass - if klass == self.parentclass + if klass == self.parentobj return true else - return self.parentclass.child_of?(klass) + return self.parentobj.child_of?(klass) end end @@ -31,15 +31,11 @@ class Puppet::Parser::AST end pnames = nil - if @parentclass - if pklass = self.parentclass - pklass.safeevaluate :scope => scope + if pklass = self.parentobj + pklass.safeevaluate :scope => scope - scope = parent_scope(scope, pklass) - pnames = scope.namespaces - else - parsefail "Could not find class %s" % @parentclass - end + scope = parent_scope(scope, pklass) + pnames = scope.namespaces end unless hash[:nosubscope] diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb index 704710dc1..e873cac46 100644 --- a/lib/puppet/parser/ast/node.rb +++ b/lib/puppet/parser/ast/node.rb @@ -19,7 +19,7 @@ class Puppet::Parser::AST # We don't have to worry about the declarativeness of node parentage, # because the entry point is always a single node definition. - if parent = self.parentclass + if parent = self.parentobj scope = parent.safeevaluate :scope => scope end @@ -53,12 +53,10 @@ class Puppet::Parser::AST end end - def parentclass - parentobj do |name| - @interp.nodesearch(name) - end - - @parentclass + private + # Search for the object matching our parent class. + def find_parentclass + @interp.nodesearch(parentclass) end end end |