Permalink
Browse files

Merge pull request #1085 from amatsuda/amo_validator_initializer_cleanup

cleanups on AMo validator initializers
  • Loading branch information...
josevalim committed May 16, 2011
2 parents 8b0262f + 35c5ccb commit 12a4376ae96f79ec0ba889a70a4390531d1d6ffd
@@ -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]
@@ -9,10 +9,6 @@ class NumericalityValidator < EachValidator
RESERVED_OPTIONS = CHECKS.keys + [:only_integer]
- def initialize(options)
- super(options.reverse_merge(:only_integer => false, :allow_nil => false))
- end
-
def check_validity!
keys = CHECKS.keys - [:odd, :even]
options.slice(*keys).each do |option, value|

0 comments on commit 12a4376

Please sign in to comment.