Merge pull request #6024 from carlosantoniodasilva/amo-dirty-refactor
Improve AMo::Dirty *_will_change! method
This commit is contained in:
commit
d0e1c692b4
@ -151,13 +151,15 @@ def attribute_was(attr)
|
|||||||
|
|
||||||
# Handle <tt>*_will_change!</tt> for +method_missing+.
|
# Handle <tt>*_will_change!</tt> for +method_missing+.
|
||||||
def attribute_will_change!(attr)
|
def attribute_will_change!(attr)
|
||||||
|
return if attribute_changed?(attr)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
value = __send__(attr)
|
value = __send__(attr)
|
||||||
value = value.duplicable? ? value.clone : value
|
value = value.duplicable? ? value.clone : value
|
||||||
rescue TypeError, NoMethodError
|
rescue TypeError, NoMethodError
|
||||||
end
|
end
|
||||||
|
|
||||||
changed_attributes[attr] = value unless changed_attributes.include?(attr)
|
changed_attributes[attr] = value
|
||||||
end
|
end
|
||||||
|
|
||||||
# Handle <tt>reset_*!</tt> for +method_missing+.
|
# Handle <tt>reset_*!</tt> for +method_missing+.
|
||||||
|
Loading…
Reference in New Issue
Block a user