aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-01-20 21:57:47 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-01-21 12:45:06 -0200
commita4cc88d0851343ac16e2294c06c5a4101189c410 (patch)
tree9ead9996df884d5c560387d3e4da5d817e686828 /activerecord/lib/active_record
parentb8302bcfdaec2a9e7658262d6feeb535c572922d (diff)
downloadrails-a4cc88d0851343ac16e2294c06c5a4101189c410.tar.gz
rails-a4cc88d0851343ac16e2294c06c5a4101189c410.tar.bz2
rails-a4cc88d0851343ac16e2294c06c5a4101189c410.zip
Extract all attribute changed work to its own method
This will make easier to hook on this feature to customize the behavior
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/attribute_methods/dirty.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb
index 19e81abba5..f7065d183f 100644
--- a/activerecord/lib/active_record/attribute_methods/dirty.rb
+++ b/activerecord/lib/active_record/attribute_methods/dirty.rb
@@ -43,6 +43,13 @@ module ActiveRecord
def write_attribute(attr, value)
attr = attr.to_s
+ save_changed_attribute(attr, value)
+
+ # Carry on.
+ super(attr, value)
+ end
+
+ def save_changed_attribute(attr, value)
# The attribute already has an unsaved change.
if attribute_changed?(attr)
old = changed_attributes[attr]
@@ -51,9 +58,6 @@ module ActiveRecord
old = clone_attribute_value(:read_attribute, attr)
changed_attributes[attr] = old if _field_changed?(attr, old, value)
end
-
- # Carry on.
- super(attr, value)
end
def update_record(*)