Class: Jets::Router::Finder
- Inherits:
-
Object
- Object
- Jets::Router::Finder
- Extended by:
- Memoist
- Defined in:
- lib/jets/router/finder.rb
Instance Method Summary collapse
-
#initialize(path, method) ⇒ Finder
constructor
A new instance of Finder.
- #run ⇒ Object
Constructor Details
#initialize(path, method) ⇒ Finder
Returns a new instance of Finder.
5 6 7 8 |
# File 'lib/jets/router/finder.rb', line 5 def initialize(path, method) @path = path @method = method.to_s.upcase end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/jets/router/finder.rb', line 10 def run reset_routes! # Precedence: # 1. Routes with no captures get highest precedence: posts/new # 2. Then we consider the routes with captures: post/:id # # Within these 2 groups we consider the routes with the longest path first # since posts/:id and posts/:id/edit can both match. routes = router.ordered_routes route = routes.find do |r| matcher.match?(r) end route end |