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:
parent
6d0895a489
commit
0334eb6dfa
1 changed files with 2 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue