1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Use Regext#match? where MatchData is not needed

This commit is contained in:
Akira Matsuda 2019-09-17 07:48:14 +09:00
parent 30a73035c7
commit 4a9ef5e120
4 changed files with 5 additions and 5 deletions

View file

@ -146,12 +146,12 @@ module ActionDispatch
missing_keys << key
end
when RegexCaseComparator
unless RegexCaseComparator::DEFAULT_REGEX === parts[key]
unless RegexCaseComparator::DEFAULT_REGEX.match?(parts[key])
missing_keys ||= []
missing_keys << key
end
else
unless /\A#{tests[key]}\Z/ === parts[key]
unless /\A#{tests[key]}\Z/.match?(parts[key])
missing_keys ||= []
missing_keys << key
end

View file

@ -48,7 +48,7 @@ module ActionDispatch
t.map { |s|
if states = @regexp_states[s]
regexps.concat states.map { |re, v| re === a ? v : nil }
regexps.concat states.map { |re, v| re.match?(a) ? v : nil }
end
if states = @string_states[s]

View file

@ -104,7 +104,7 @@ module Arel # :nodoc: all
return o if o.orders.empty?
return o unless o.cores.any? do |core|
core.projections.any? do |projection|
/FIRST_VALUE/ === projection
/FIRST_VALUE/.match?(projection)
end
end
# Previous version with join and split broke ORDER BY clause

View file

@ -42,7 +42,7 @@ module ActiveRecord
ensure
failed_patterns = []
patterns_to_match.each do |pattern|
failed_patterns << pattern unless SQLCounter.log_all.any? { |sql| pattern === sql }
failed_patterns << pattern unless SQLCounter.log_all.any? { |sql| pattern.match?(sql) }
end
assert failed_patterns.empty?, "Query pattern(s) #{failed_patterns.map(&:inspect).join(', ')} not found.#{SQLCounter.log.size == 0 ? '' : "\nQueries:\n#{SQLCounter.log.join("\n")}"}"
end