Permalink
Browse files

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
  • Loading branch information...
1 parent 4e9f53f commit 454d820bf0a18fe1db4c55b0145197d70fef1f82 @rafaelfranca rafaelfranca committed Oct 3, 2012
Showing with 7 additions and 5 deletions.
  1. +7 −5 activemodel/lib/active_model/validations.rb
View
12 activemodel/lib/active_model/validations.rb
@@ -195,12 +195,14 @@ def validators
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

0 comments on commit 454d820

Please sign in to comment.