Rename rollback_changes to undo_changes

To avoid overload with database rollback
This commit is contained in:
Rafael Mendonça França 2014-06-30 16:55:01 -03:00
parent b34f7c1706
commit dc67d3d2a1
3 changed files with 6 additions and 6 deletions

View File

@ -1,4 +1,4 @@
* Added `rollback_changes` method to `ActiveModel::Dirty` API to roolback all the
* Added `undo_changes` method to `ActiveModel::Dirty` API to restore all the
changed values to the previous data.
*Igor G.*

View File

@ -17,7 +17,7 @@ module ActiveModel
# * Call <tt>changes_applied</tt> after the changes are persisted.
# * Call <tt>reset_changes</tt> when you want to reset the changes
# information.
# * Call <tt>rollback_changes</tt> when you want to restore previous data
# * Call <tt>undo_changes</tt> when you want to restore previous data.
#
# A minimal implementation could be:
#
@ -45,7 +45,7 @@ module ActiveModel
# end
#
# def rollback!
# rollback_changes
# undo_changes
# end
# end
#
@ -191,7 +191,7 @@ module ActiveModel
end
# Restore all previous data.
def rollback_changes # :doc:
def undo_changes # :doc:
changed_attributes.each_key { |attr| reset_attribute! attr }
end

View File

@ -47,7 +47,7 @@ class DirtyTest < ActiveModel::TestCase
end
def rollback
rollback_changes
undo_changes
end
end
@ -181,7 +181,7 @@ class DirtyTest < ActiveModel::TestCase
assert_equal ActiveSupport::HashWithIndifferentAccess.new, @model.changed_attributes
end
test "rollback should restore all previous data" do
test "undo_changes should restore all previous data" do
@model.name = 'Dmitry'
@model.color = 'Red'
@model.save