aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-12-24 12:48:45 -0800
committerJosé Valim <jose.valim@gmail.com>2011-12-24 12:48:45 -0800
commitb28ed2bd4fb094c9420d14b858cebb47373e48d8 (patch)
tree3776b73227b59864f6d6c2fe4c705b463252bc4a
parent0d7c3757a9ad96b0e8aa67fc93c389890c989fd0 (diff)
parentfdbd6779fe1a9d54c55b401f4b2a92b5e5ef1e8f (diff)
downloadrails-b28ed2bd4fb094c9420d14b858cebb47373e48d8.tar.gz
rails-b28ed2bd4fb094c9420d14b858cebb47373e48d8.tar.bz2
rails-b28ed2bd4fb094c9420d14b858cebb47373e48d8.zip
Merge pull request #4172 from nashby/refactor-tokenizer
don't call an extra method if options[:tokenizer] is not present
-rw-r--r--activemodel/lib/active_model/validations/length.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index f91fc3a750..0eba241333 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -56,10 +56,8 @@ module ActiveModel
private
def tokenize(value)
- if value.kind_of?(String)
- if options[:tokenizer]
- options[:tokenizer].call(value)
- end
+ if options[:tokenizer] && value.kind_of?(String)
+ options[:tokenizer].call(value)
end || value
end
end