lib/puppet/propertychange.rb in puppet-0.22.4 vs lib/puppet/propertychange.rb in puppet-0.23.0

- old
+ new

@@ -12,23 +12,23 @@ attr_reader :report # Switch the goals of the property, thus running the change in reverse. def backward @property.should = @is - @property.retrieve + @is = @property.retrieve unless defined? @transaction raise Puppet::Error, "PropertyChange '%s' tried to be executed outside of transaction" % self end - unless @property.insync? + unless @property.insync?(@is) @property.info "Backing %s" % self return self.go else @property.debug "rollback is already in sync: %s vs. %s" % - [@property.is.inspect, @property.should.inspect] + [@is, @property.should.inspect] return nil end end def changed? @@ -40,28 +40,28 @@ # default to a simple event type unless name.is_a?(Symbol) @property.warning("Property '%s' returned invalid event '%s'; resetting to default" % [@property.class,event]) - event = @property.parent.class.name.id2name + "_changed" + event = @property.resource.class.name.id2name + "_changed" end Puppet::Event.new( :event => name, :transaction => @transaction, :source => self.source ) end - def initialize(property) + def initialize(property, currentvalue) unless property.is_a?(Puppet::Type::Property) raise Puppet::DevError, "Got a %s instead of a property" % property.class end @property = property @path = [property.path,"change"].flatten - @is = property.is + @is = currentvalue @should = property.should @changed = false end @@ -90,11 +90,11 @@ else events = [events] end return events.collect { |name| - @report = @property.log(@property.change_to_s) + @report = @property.log(@property.change_to_s(@is, @should)) event(name) } end def forward @@ -112,32 +112,32 @@ def noop return @property.noop end def skip? - if @property.insync? + if @property.insync?(@is) @property.info "Already in sync" return true end if @property.noop @property.log "is %s, should be %s (noop)" % - [property.is_to_s, property.should_to_s] + [property.is_to_s(@is), property.should_to_s(@should)] #@property.debug "%s is noop" % @property return true end return false end def source - self.proxy || @property.parent + self.proxy || @property.resource end def to_s return "change %s.%s(%s)" % - [@transaction.object_id, self.object_id, @property.change_to_s] + [@transaction.object_id, self.object_id, @property.change_to_s(@is, @should)] #return "change %s.%s" % [@transaction.object_id, self.object_id] end end end -# $Id: propertychange.rb 2286 2007-03-17 23:16:37Z luke $ +# $Id: propertychange.rb 2500 2007-05-09 22:05:32Z luke $