From 089e1b6426719ad5132153323d23798094d271fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 23 Sep 2013 11:00:41 -0300 Subject: Document reset_changes since it is part of public API [ci skip] --- activemodel/lib/active_model/dirty.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 attr_name_will_change! before each change to the tracked # attribute. # * Call changes_applied after the changes are persisted. + # * Call reset_changes 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' -- cgit v1.2.3