Permalink
Browse files

Add ActiveModel::Errors#delete, which was not available after move to…

… use delegation
  • Loading branch information...
1 parent 3100b99 commit 8e8982cf3bd6358c1639a4def8970f932a9b8980 @drogus drogus committed Jan 16, 2012
Showing with 12 additions and 0 deletions.
  1. +5 −0 activemodel/lib/active_model/errors.rb
  2. +7 −0 activemodel/test/cases/errors_test.rb
@@ -99,6 +99,11 @@ def set(key, value)
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.
#
@@ -27,6 +27,13 @@ def self.lookup_ancestors
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'

0 comments on commit 8e8982c

Please sign in to comment.