From 454d820bf0a18fe1db4c55b0145197d70fef1f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 2 Oct 2012 23:24:42 -0300 Subject: 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 --- activemodel/lib/active_model/validations.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'activemodel/lib/active_model') 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 -- cgit v1.2.3