diff options
author | José Valim <jose.valim@gmail.com> | 2009-12-23 12:14:00 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2009-12-23 12:14:00 +0100 |
commit | 44cd9e0e7132abe632664377f13f3edd1106685a (patch) | |
tree | 71373ffe546443361cb9e33010de8c73a835c073 /activemodel/lib/active_model/validations/numericality.rb | |
parent | 279067639f319f3b4bbcaf90c26f286e96df2c77 (diff) | |
download | rails-44cd9e0e7132abe632664377f13f3edd1106685a.tar.gz rails-44cd9e0e7132abe632664377f13f3edd1106685a.tar.bz2 rails-44cd9e0e7132abe632664377f13f3edd1106685a.zip |
ActiveRecord::Validations are now built on top of Validator as well.
Diffstat (limited to 'activemodel/lib/active_model/validations/numericality.rb')
-rw-r--r-- | activemodel/lib/active_model/validations/numericality.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 914a3133cf..f2aab8c5b8 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -5,6 +5,10 @@ module ActiveModel :equal_to => :==, :less_than => :<, :less_than_or_equal_to => :<=, :odd => :odd?, :even => :even? }.freeze + def initialize(options) + super(options.reverse_merge(:only_integer => false, :allow_nil => false)) + end + def check_validity! options.slice(*CHECKS.keys) do |option, value| next if [:odd, :even].include?(option) @@ -99,8 +103,7 @@ module ActiveModel # end # def validates_numericality_of(*attr_names) - options = { :only_integer => false, :allow_nil => false } - options.update(attr_names.extract_options!) + options = attr_names.extract_options! validates_with NumericalityValidator, options.merge(:attributes => attr_names) end end |