diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-11-26 15:09:19 -0500 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2018-11-26 15:10:25 -0500 |
commit | db080527a4b6915b1ae7d9bc678467990ecece61 (patch) | |
tree | c960b8037c10c85973b069b946f4f8221d02dee0 /activemodel | |
parent | 713e75d46dc75274a996661ed3ff773bc481d7a5 (diff) | |
download | rails-db080527a4b6915b1ae7d9bc678467990ecece61.tar.gz rails-db080527a4b6915b1ae7d9bc678467990ecece61.tar.bz2 rails-db080527a4b6915b1ae7d9bc678467990ecece61.zip |
Do not use deprecated Object#!~ in Ruby 2.6
Closes #34530.
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/validations/numericality.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 126a87ac6e..b9ae42fd39 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -86,13 +86,17 @@ module ActiveModel def parse_raw_value_as_a_number(raw_value) return raw_value.to_i if is_integer?(raw_value) - Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/ + Kernel.Float(raw_value) unless is_hexadecimal_literal?(raw_value) end def is_integer?(raw_value) /\A[+-]?\d+\z/ === raw_value.to_s end + def is_hexadecimal_literal?(raw_value) + /\A0[xX]/ === raw_value + end + def filtered_options(value) filtered = options.except(*RESERVED_OPTIONS) filtered[:value] = value |