Class: Dolphy::Router
- Inherits:
-
Object
- Object
- Dolphy::Router
- Defined in:
- lib/dolphy/router.rb
Constant Summary collapse
- HTTP_METHODS =
i(get post put delete head patch trace)
Instance Attribute Summary collapse
-
#routes ⇒ Object
Returns the value of attribute routes.
Instance Method Summary collapse
- #find_match_data_for(request, with:) ⇒ Object
- #find_route_for(request) ⇒ Object
-
#initialize ⇒ Router
constructor
A new instance of Router.
Constructor Details
#initialize ⇒ Router
Returns a new instance of Router.
7 8 9 |
# File 'lib/dolphy/router.rb', line 7 def initialize @routes = Hash.new { |h, k| h[k] = [] } end |
Instance Attribute Details
#routes ⇒ Object
Returns the value of attribute routes.
3 4 5 |
# File 'lib/dolphy/router.rb', line 3 def routes @routes end |
Instance Method Details
#find_match_data_for(request, with:) ⇒ Object
15 16 17 |
# File 'lib/dolphy/router.rb', line 15 def find_match_data_for(request, with:) trim_trailing_slash(request.path_info).match(with) end |
#find_route_for(request) ⇒ Object
11 12 13 |
# File 'lib/dolphy/router.rb', line 11 def find_route_for(request) routes[request.http_method] end |