aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-02 23:24:42 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-10-02 23:24:42 -0300
commit454d820bf0a18fe1db4c55b0145197d70fef1f82 (patch)
tree833a7e737d33328067810eec1e615b76104945c2 /activemodel/lib/active_model
parent4e9f53f9736544f070e75e516c71137b7eb49a7a (diff)
downloadrails-454d820bf0a18fe1db4c55b0145197d70fef1f82.tar.gz
rails-454d820bf0a18fe1db4c55b0145197d70fef1f82.tar.bz2
rails-454d820bf0a18fe1db4c55b0145197d70fef1f82.zip
Don't use tap in this case.
The use of tap in this case is very confusing since we are mutating the return value inside the block
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r--activemodel/lib/active_model/validations.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb
index 5a3225a7e6..be780d570b 100644
--- a/activemodel/lib/active_model/validations.rb
+++ b/activemodel/lib/active_model/validations.rb
@@ -195,12 +195,14 @@ module ActiveModel
def validators_on(*attributes)
options = attributes.extract_options!
- attributes.map do |attribute|
+ validators = attributes.map do |attribute|
_validators[attribute.to_sym]
- end.flatten.tap do |validators|
- if options[:kind]
- validators.select! { |validator| validator.kind == options[:kind] }
- end
+ end.flatten
+
+ if options[:kind]
+ validators.select! { |validator| validator.kind == options[:kind] }
+ else
+ validators
end
end