diff options
| author | Luke Kanies <luke@madstop.com> | 2007-11-08 12:18:42 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2007-11-08 12:18:42 -0600 |
| commit | dfe774f55e98db085d8f5729a4b1229513c6c2b0 (patch) | |
| tree | 39915f08eff31c0d6f690e05b7ebb3f594338536 /lib/puppet | |
| parent | f465e7e96d62f9b18bdebd51319582d5b2ffa332 (diff) | |
| download | puppet-dfe774f55e98db085d8f5729a4b1229513c6c2b0.tar.gz puppet-dfe774f55e98db085d8f5729a4b1229513c6c2b0.tar.xz puppet-dfe774f55e98db085d8f5729a4b1229513c6c2b0.zip | |
Switching the base class for the Relationship class.
It was previously using the GRATR::Edge class, which
had wonky overrides that dramatically slowed down
sorting (its hash mechanism hashed the source and
target so that edges with the same source/target got
the same hash, which we actually don't want any more).
This shouldn't change any functionality, just performance.
I didn't retain all functionality from the Edge class, but
a lot of that functionality was, um, horrible, like Edge[]
being equivalent to Edge.new.
Diffstat (limited to 'lib/puppet')
| -rw-r--r-- | lib/puppet/metatype/relationships.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/relationship.rb | 17 |
2 files changed, 11 insertions, 8 deletions
diff --git a/lib/puppet/metatype/relationships.rb b/lib/puppet/metatype/relationships.rb index c7a0a91ee..4fb78ae56 100644 --- a/lib/puppet/metatype/relationships.rb +++ b/lib/puppet/metatype/relationships.rb @@ -40,7 +40,7 @@ class Puppet::Type end end - reqs << Puppet::Relationship[dep, self] + reqs << Puppet::Relationship.new(dep, self) } } diff --git a/lib/puppet/relationship.rb b/lib/puppet/relationship.rb index 0b958fa39..c611928f2 100644 --- a/lib/puppet/relationship.rb +++ b/lib/puppet/relationship.rb @@ -3,12 +3,15 @@ # Created by Luke A. Kanies on 2006-11-24. # Copyright (c) 2006. All rights reserved. -require 'puppet/external/gratr' - # subscriptions are permanent associations determining how different # objects react to an event -class Puppet::Relationship < GRATR::Edge +# This is Puppet's class for modeling edges in its configuration graph. +# It used to be a subclass of GRATR::Edge, but that class has weird hash +# overrides that dramatically slow down the graphing. +class Puppet::Relationship + attr_accessor :source, :target, :label + # Return the callback def callback if label @@ -30,17 +33,17 @@ class Puppet::Relationship < GRATR::Edge def initialize(source, target, label = {}) if label unless label.is_a?(Hash) - raise Puppet::DevError, "The label must be a hash" + raise ArgumentError, "Relationship labels must be a hash" end if label[:event] and label[:event] != :NONE and ! label[:callback] - raise Puppet::DevError, "You must pass a callback for non-NONE events" + raise ArgumentError, "You must pass a callback for non-NONE events" end else label = {} end - - super(source, target, label) + + @source, @target, @label = source, target, label end # Does the passed event match our event? This is where the meaning |
