Document reset_changes since it is part of public API
[ci skip]
This commit is contained in:
parent
9aa1a3d853
commit
089e1b6426
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user