diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-11-15 00:19:28 -0200 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-11-15 00:24:54 -0200 |
commit | 70161ae3b890bb6b0603470709432a1bec911da7 (patch) | |
tree | 0643efd015498cfe30436a59f8773759a2697ae8 /activemodel/lib/active_model/validations | |
parent | 12815e0d44faf1154bebe5703577ff56c13688bc (diff) | |
download | rails-70161ae3b890bb6b0603470709432a1bec911da7.tar.gz rails-70161ae3b890bb6b0603470709432a1bec911da7.tar.bz2 rails-70161ae3b890bb6b0603470709432a1bec911da7.zip |
Make code simpler to read by using a case statement
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r-- | activemodel/lib/active_model/validations/numericality.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 5acd4477ff..c8d3236463 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -44,8 +44,12 @@ module ActiveModel record.errors.add(attr_name, option, filtered_options(value)) end else - option_value = option_value.call(record) if option_value.is_a?(Proc) - option_value = record.send(option_value) if option_value.is_a?(Symbol) + case option_value + when Proc + option_value = option_value.call(record) + when Symbol + option_value = record.send(option_value) + end unless value.send(CHECKS[option], option_value) record.errors.add(attr_name, option, filtered_options(value).merge!(count: option_value)) |