Permalink
Browse files

Don't add DEFAULT_TOKENIZER to every instance of LengthValidator. Jus…

…t use it only when needed.
  • Loading branch information...
1 parent 8b0262f commit cbe1d2488b12460dd752a3805ea813f37e4fe94e @amatsuda amatsuda committed May 16, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 activemodel/lib/active_model/validations/length.rb
@@ -16,7 +16,7 @@ def initialize(options)
options[:maximum] -= 1 if range.exclude_end?
end
- super(options.reverse_merge(:tokenizer => DEFAULT_TOKENIZER))
+ super
end
def check_validity!
@@ -36,7 +36,7 @@ def check_validity!
end
def validate_each(record, attribute, value)
- value = options[:tokenizer].call(value) if value.kind_of?(String)
+ value = (options[:tokenizer] || DEFAULT_TOKENIZER).call(value) if value.kind_of?(String)
CHECKS.each do |key, validity_check|
next unless check_value = options[key]

0 comments on commit cbe1d24

Please sign in to comment.