diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2012-01-16 17:22:44 +0100 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2012-01-16 17:24:08 +0100 |
commit | 3430647434a94226a3fbed4587ef3b4bea7fe6f9 (patch) | |
tree | a11b7673c37f2d42067de45fe6aacce23667cd0d /activemodel | |
parent | 42159354b4ee6145fe3fa9e169af48380c6134e0 (diff) | |
download | rails-3430647434a94226a3fbed4587ef3b4bea7fe6f9.tar.gz rails-3430647434a94226a3fbed4587ef3b4bea7fe6f9.tar.bz2 rails-3430647434a94226a3fbed4587ef3b4bea7fe6f9.zip |
Add ActiveModel::Errors#delete, which was not available after move to use delegation
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 5 | ||||
-rw-r--r-- | activemodel/test/cases/errors_test.rb | 7 |
2 files changed, 12 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index aafd1c8a74..3d814b4870 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -100,6 +100,11 @@ module ActiveModel messages[key] = value end + # Delete messages for +key+ + def delete(key) + messages.delete(key) + end + # When passed a symbol or a name of a method, returns an array of errors # for the method. # diff --git a/activemodel/test/cases/errors_test.rb b/activemodel/test/cases/errors_test.rb index 8ddedb160a..4edeece3e8 100644 --- a/activemodel/test/cases/errors_test.rb +++ b/activemodel/test/cases/errors_test.rb @@ -27,6 +27,13 @@ class ErrorsTest < ActiveModel::TestCase end end + def test_delete + errors = ActiveModel::Errors.new(self) + errors[:foo] = 'omg' + errors.delete(:foo) + assert_empty errors[:foo] + end + def test_include? errors = ActiveModel::Errors.new(self) errors[:foo] = 'omg' |