Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Further simplification to DirtyMinder

* No need to set the resource to a specific value before triggering
  dirty tracking, and just set it to nil.
* No need to track "before" since all we really care about is it's hash value
* No need to track "after" either since that's just self and we can get at
  it anytime.
  • Loading branch information...
1 parent 9af29d6 commit 356a30514a5d8b63bb99d53c8b33de4841364d21 @dkubb dkubb committed
Showing with 5 additions and 6 deletions.
  1. +5 −6 lib/dm-types/support/dirty_minder.rb
11 lib/dm-types/support/dirty_minder.rb
@@ -104,9 +104,8 @@ def self.extended(instance)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
module #{klass}Hooks
def #{meth}(*)
- before = self.clone
- ret = super
- after = self
+ original_hash = hash
+ ret = super
# If the hashes aren't equivalent then we know the Resource
# should be dirty. However because we mutated self, normal
@@ -118,9 +117,9 @@ def #{meth}(*)
# tracking and set the value of the property directly to the
# previous value (a different object now, because it's a clone).
# Then trigger the State tracking like normal.
- if before.hash != after.hash
- @property.set(@resource, before)
- @resource.attribute_set(, after)
+ if original_hash != hash
+ @property.set(@resource, nil)
+ @resource.attribute_set(, self)

0 comments on commit 356a305

Please sign in to comment.
Something went wrong with that request. Please try again.