diff options
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/type.rb | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 0a6ccdaa4..b7ff1f664 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -316,19 +316,22 @@ class Type def parent return nil unless configuration - # This is kinda weird. - if implicit? - parents = configuration.relationship_graph.adjacent(self, :direction => :in) - else - parents = configuration.adjacent(self, :direction => :in) - end - if parents - # We should never have more than one parent, so let's just ignore - # it if we happen to. - return parents.shift - else - return nil + unless defined?(@parent) + # This is kinda weird. + if implicit? + parents = configuration.relationship_graph.adjacent(self, :direction => :in) + else + parents = configuration.adjacent(self, :direction => :in) + end + if parents + # We should never have more than one parent, so let's just ignore + # it if we happen to. + @parent = parents.shift + else + @parent = nil + end end + @parent end # Return the "type[name]" style reference. |
