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

Simplify route score

This commit is contained in:
Vinicius Stock 2020-03-03 09:07:24 -05:00
parent 6d0895a489
commit 0334eb6dfa
No known key found for this signature in database
GPG key ID: 1A3EC85374C0969A

View file

@ -110,18 +110,11 @@ module ActionDispatch
end
def score(supplied_keys)
required_keys = path.required_names
required_keys.each do |k|
path.required_names.each do |k|
return -1 unless supplied_keys.include?(k)
end
score = 0
path.names.each do |k|
score += 1 if supplied_keys.include?(k)
end
score + (required_defaults.length * 2)
(required_defaults.length * 2) + path.names.count { |k| supplied_keys.include?(k) }
end
def parts