aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-30 15:41:41 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-06-30 15:41:41 -0300
commitb34f7c1706bbe20c1dc334884f9ba5ae7182f9f2 (patch)
tree22de3e995f7591e5a0297aaf4549efd015805a90 /activemodel
parentbada1d3ed6a5d8879805ace8277711ae1efc18c8 (diff)
downloadrails-b34f7c1706bbe20c1dc334884f9ba5ae7182f9f2.tar.gz
rails-b34f7c1706bbe20c1dc334884f9ba5ae7182f9f2.tar.bz2
rails-b34f7c1706bbe20c1dc334884f9ba5ae7182f9f2.zip
Add CHANGELOG entry for #14861 and document private methods on the API
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/CHANGELOG.md5
-rw-r--r--activemodel/lib/active_model/dirty.rb10
2 files changed, 10 insertions, 5 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index 890e99415f..8bae40d59b 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Added `rollback_changes` method to `ActiveModel::Dirty` API to roolback all the
+ changed values to the previous data.
+
+ *Igor G.*
+
* Allow proc and symbol as values for `only_integer` of `NumericalityValidator`
*Robin Mehner*
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb
index 95a3c00d0b..e5bfee2291 100644
--- a/activemodel/lib/active_model/dirty.rb
+++ b/activemodel/lib/active_model/dirty.rb
@@ -179,19 +179,19 @@ module ActiveModel
private
# Removes current changes and makes them accessible through +previous_changes+.
- def changes_applied
+ def changes_applied # :doc:
@previously_changed = changes
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
end
- # Removes all dirty data: current changes and previous changes
- def reset_changes
+ # Removes all dirty data: current changes and previous changes.
+ def reset_changes # :doc:
@previously_changed = ActiveSupport::HashWithIndifferentAccess.new
@changed_attributes = ActiveSupport::HashWithIndifferentAccess.new
end
- # Restore all previous data
- def rollback_changes #:doc:
+ # Restore all previous data.
+ def rollback_changes # :doc:
changed_attributes.each_key { |attr| reset_attribute! attr }
end