From dc67d3d2a1480f82ffcce418cf4bcad5dfb2a177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 30 Jun 2014 16:55:01 -0300 Subject: Rename rollback_changes to undo_changes To avoid overload with database rollback --- activemodel/CHANGELOG.md | 2 +- activemodel/lib/active_model/dirty.rb | 6 +++--- 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 changes_applied after the changes are persisted. # * Call reset_changes when you want to reset the changes # information. - # * Call rollback_changes when you want to restore previous data + # * Call undo_changes 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 -- cgit v1.2.3