diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-14 15:19:48 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2007-05-14 15:19:48 +0000 |
commit | 27cabf25fc08ee77df08ec65a440f9d164b9215d (patch) | |
tree | 558ae2a8d0709c75c53601afa1021125dc9d4950 /lib | |
parent | 613c413cd84a690f1fb0cb625380e430bc502c84 (diff) | |
download | puppet-27cabf25fc08ee77df08ec65a440f9d164b9215d.tar.gz puppet-27cabf25fc08ee77df08ec65a440f9d164b9215d.tar.xz puppet-27cabf25fc08ee77df08ec65a440f9d164b9215d.zip |
Fixing a weird bug that occurred because I was changing @parentclass in the AST stuff the first time it was called, from a string to a the actual instance of the parent. This worked fine as long as the parentclass was only called when parsing was complete, such as during evaluation, but if anything resulted in it being called earlier (e.g., attempting to add to the class during parsing), then things behaved, um, badly. This commit fixes the method so that the variable is not modified; there is now @parentclass and @parentobj.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2511 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-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 |