aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-23 11:00:41 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-09-23 11:00:56 -0300
commit089e1b6426719ad5132153323d23798094d271fa (patch)
tree6a6ac2fa8692696e40188d35758c3be7f967aeda /activemodel/lib
parent9aa1a3d85327fa0a3055b5b757a0be092ce582f7 (diff)
downloadrails-089e1b6426719ad5132153323d23798094d271fa.tar.gz
rails-089e1b6426719ad5132153323d23798094d271fa.tar.bz2
rails-089e1b6426719ad5132153323d23798094d271fa.zip
Document reset_changes since it is part of public API
[ci skip]
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/dirty.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb
index be2759b141..0b17443219 100644
--- a/activemodel/lib/active_model/dirty.rb
+++ b/activemodel/lib/active_model/dirty.rb
@@ -15,6 +15,8 @@ module ActiveModel
# * Call <tt>attr_name_will_change!</tt> before each change to the tracked
# attribute.
# * Call <tt>changes_applied</tt> after the changes are persisted.
+ # * Call <tt>reset_changes</tt> when you want to reset the changes
+ # information.
#
# A minimal implementation could be:
#
@@ -36,6 +38,10 @@ module ActiveModel
# # do persistence work
# changes_applied
# end
+ #
+ # def reload!
+ # reset_changes
+ # end
# end
#
# A newly instantiated object is unchanged:
@@ -59,6 +65,12 @@ module ActiveModel
# person.changed? # => false
# person.name_changed? # => false
#
+ # Reset the changes:
+ #
+ # person.previous_changes # => {"name" => ["Uncle Bob", "Bill"]}
+ # person.reload
+ # person.previous_changes # => {}
+ #
# Assigning the same value leaves the attribute unchanged:
#
# person.name = 'Bill'