diff options
author | Luke Kanies <luke@madstop.com> | 2008-07-04 15:35:18 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-07-04 15:35:18 -0500 |
commit | 2863df288150da87a58ce4d938bbcf9a5d841f43 (patch) | |
tree | 571c8de49b1133655551f6a43dd7f4ec39d28e30 /lib | |
parent | a37a7845073ef0b0923549364cbac5e0e39e3194 (diff) | |
download | puppet-2863df288150da87a58ce4d938bbcf9a5d841f43.tar.gz puppet-2863df288150da87a58ce4d938bbcf9a5d841f43.tar.xz puppet-2863df288150da87a58ce4d938bbcf9a5d841f43.zip |
Refactoring the Transaction::Event class.
The class had a 'transaction' accessor that was assigned
but never used, and it is simple enough that it needed
direct arguments rather than named arguments.
The rest of the code is changing the other classes that use
Events.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/pgraph.rb | 2 | ||||
-rw-r--r-- | lib/puppet/transaction.rb | 16 | ||||
-rw-r--r-- | lib/puppet/transaction/change.rb | 6 | ||||
-rw-r--r-- | lib/puppet/transaction/event.rb | 9 |
4 files changed, 10 insertions, 23 deletions
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb index 3bcc2ced0..55ad7d2c1 100644 --- a/lib/puppet/pgraph.rb +++ b/lib/puppet/pgraph.rb @@ -58,7 +58,7 @@ class Puppet::PGraph < Puppet::SimpleGraph # to, which is the same thing as saying all edges directly below # This vertex in the graph. adjacent(source, :direction => :out, :type => :edges).find_all do |edge| - edge.match?(event.event) + edge.match?(event.name) end end.compact.flatten end diff --git a/lib/puppet/transaction.rb b/lib/puppet/transaction.rb index 78704bb13..695d0434c 100644 --- a/lib/puppet/transaction.rb +++ b/lib/puppet/transaction.rb @@ -98,7 +98,7 @@ class Transaction # Create an edge with this resource as both the source and # target. The triggering method treats these specially for # logging. - events = resourceevents.collect { |e| e.event } + events = resourceevents.collect { |e| e.name } set_trigger(Puppet::Relationship.new(resource, resource, :callback => :refresh, :event => events)) end end @@ -280,7 +280,7 @@ class Transaction # of course, bad. edge = orig_edge.class.new(orig_edge.source, orig_edge.target) label = orig_edge.label.dup - label[:event] = events.collect { |e| e.event } + label[:event] = events.collect { |e| e.name } edge.label = label set_trigger(edge) end @@ -682,11 +682,7 @@ class Transaction [callback, subs.length] # And then add an event for it. - return [Puppet::Transaction::Event.new( - :event => :noop, - :transaction => self, - :source => resource - )] + return [Puppet::Transaction::Event.new(:noop, resource)] end if subs.length == 1 and subs[0].source == resource @@ -714,11 +710,7 @@ class Transaction end # And then add an event for it. - trigged << Puppet::Transaction::Event.new( - :event => :triggered, - :transaction => self, - :source => resource - ) + trigged << Puppet::Transaction::Event.new(:triggered, resource) triggered(resource, callback) end diff --git a/lib/puppet/transaction/change.rb b/lib/puppet/transaction/change.rb index e1863ee13..cc7629376 100644 --- a/lib/puppet/transaction/change.rb +++ b/lib/puppet/transaction/change.rb @@ -43,11 +43,7 @@ class Puppet::Transaction::Change name = @property.event(should) end - Puppet::Transaction::Event.new( - :event => name, - :transaction => transaction, - :source => self.resource - ) + Puppet::Transaction::Event.new(name, self.resource) end def initialize(property, currentvalue) diff --git a/lib/puppet/transaction/event.rb b/lib/puppet/transaction/event.rb index 418e70516..f1a48b382 100644 --- a/lib/puppet/transaction/event.rb +++ b/lib/puppet/transaction/event.rb @@ -9,14 +9,13 @@ class Puppet::Transaction::Event include Puppet::Util::MethodHelper include Puppet::Util::Errors - attr_accessor :event, :source, :transaction + attr_reader :name, :source - def initialize(args) - set_options symbolize_options(args) - requiredopts(:event, :source) + def initialize(name, source) + @name, @source = name, source end def to_s - @source.to_s + " -> " + self.event.to_s + source.to_s + " -> " + name.to_s end end |