diff options
author | Akira Matsuda <ronnie@dio.jp> | 2019-07-27 12:56:39 +0900 |
---|---|---|
committer | Akira Matsuda <ronnie@dio.jp> | 2019-07-27 13:06:49 +0900 |
commit | d1ffe59ab5fd6e811833c127d43b32e87b5d7131 (patch) | |
tree | c866689e6b51b1f7eac9e49212d2938d56f6ecb2 /activerecord/lib/active_record/attribute_methods | |
parent | e9651deea4145f62224af56af027bfbb3e45e4cd (diff) | |
download | rails-d1ffe59ab5fd6e811833c127d43b32e87b5d7131.tar.gz rails-d1ffe59ab5fd6e811833c127d43b32e87b5d7131.tar.bz2 rails-d1ffe59ab5fd6e811833c127d43b32e87b5d7131.zip |
Use match? where we don't need MatchData
We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/query.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/query.rb b/activerecord/lib/active_record/attribute_methods/query.rb index 0cf67644af..5a21e36cc7 100644 --- a/activerecord/lib/active_record/attribute_methods/query.rb +++ b/activerecord/lib/active_record/attribute_methods/query.rb @@ -17,7 +17,7 @@ module ActiveRecord when false, nil then false else if !type_for_attribute(attr_name) { false } - if Numeric === value || value !~ /[^0-9]/ + if Numeric === value || !value.match?(/[^0-9]/) !value.to_i.zero? else return false if ActiveModel::Type::Boolean::FALSE_VALUES.include?(value) |