aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2019-07-20 21:26:43 +0200
committerEdouard CHIN <edouard.chin@shopify.com>2019-07-20 21:26:43 +0200
commitab21db050d9cd64628768af3fa4b650550667550 (patch)
treeaa9638b248c7a0f25ce66e1bc6e8058339ba2883 /activemodel/lib
parent400b2103540e1dfb370eab29a891687d778ad357 (diff)
downloadrails-ab21db050d9cd64628768af3fa4b650550667550.tar.gz
rails-ab21db050d9cd64628768af3fa4b650550667550.tar.bz2
rails-ab21db050d9cd64628768af3fa4b650550667550.zip
Fix deprecation on `AM::Errors` when each is called indirectly:
- `AM::Errors#each` is implemented for the `Enumerator` module and get called indirectly by a bunch of method in the ruby land (map, first, select ...) These methods have a `-1` arity as they are written in C and they wrongly trigger a deprecation warning. This commit fixes that and correctectly return a `AM::Error` object when `each` is called with a negative arity.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/errors.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb
index 22839bd9fb..5628a59845 100644
--- a/activemodel/lib/active_model/errors.rb
+++ b/activemodel/lib/active_model/errors.rb
@@ -220,7 +220,7 @@ module ActiveModel
# # then yield :name and "must be specified"
# end
def each(&block)
- if block.arity == 1
+ if block.arity <= 1
@errors.each(&block)
else
ActiveSupport::Deprecation.warn(<<~MSG)