From db080527a4b6915b1ae7d9bc678467990ecece61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 26 Nov 2018 15:09:19 -0500 Subject: Do not use deprecated Object#!~ in Ruby 2.6 Closes #34530. --- activemodel/lib/active_model/validations/numericality.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activemodel/lib') 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 -- cgit v1.2.3