Permalink
Browse files

Merge pull request #6024 from carlosantoniodasilva/amo-dirty-refactor

Improve AMo::Dirty *_will_change! method
  • Loading branch information...
2 parents dd5524a + 9d1f6ed commit d0e1c692b455093ca958a70e2d729b8b17b3f02b @josevalim josevalim committed Apr 28, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 activemodel/lib/active_model/dirty.rb
@@ -151,13 +151,15 @@ def attribute_was(attr)
# Handle <tt>*_will_change!</tt> for +method_missing+.
def attribute_will_change!(attr)
+ return if attribute_changed?(attr)
+
begin
value = __send__(attr)
value = value.duplicable? ? value.clone : value
rescue TypeError, NoMethodError
end
- changed_attributes[attr] = value unless changed_attributes.include?(attr)
+ changed_attributes[attr] = value
end
# Handle <tt>reset_*!</tt> for +method_missing+.

0 comments on commit d0e1c69

Please sign in to comment.