diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-30 16:55:01 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-06-30 16:55:01 -0300 |
commit | dc67d3d2a1480f82ffcce418cf4bcad5dfb2a177 (patch) | |
tree | 27f6899bf783b49cdf7e7126d54bd0aed6508861 | |
parent | b34f7c1706bbe20c1dc334884f9ba5ae7182f9f2 (diff) | |
download | rails-dc67d3d2a1480f82ffcce418cf4bcad5dfb2a177.tar.gz rails-dc67d3d2a1480f82ffcce418cf4bcad5dfb2a177.tar.bz2 rails-dc67d3d2a1480f82ffcce418cf4bcad5dfb2a177.zip |
Rename rollback_changes to undo_changes
To avoid overload with database rollback
-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 |