diff options
-rw-r--r-- | activemodel/CHANGELOG.md | 2 | ||||
-rw-r--r-- | activemodel/lib/active_model/dirty.rb | 6 | ||||
-rw-r--r-- | activemodel/test/cases/dirty_test.rb | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md index 8bae40d59b..2565b24c97 100644 --- a/activemodel/CHANGELOG.md +++ b/activemodel/CHANGELOG.md @@ -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.* diff --git a/activemodel/lib/active_model/dirty.rb b/activemodel/lib/active_model/dirty.rb index e5bfee2291..dc6088a39a 100644 --- a/activemodel/lib/active_model/dirty.rb +++ b/activemodel/lib/active_model/dirty.rb @@ -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 diff --git a/activemodel/test/cases/dirty_test.rb b/activemodel/test/cases/dirty_test.rb index d39484a7b9..562fadbb85 100644 --- a/activemodel/test/cases/dirty_test.rb +++ b/activemodel/test/cases/dirty_test.rb @@ -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 |