Class: Dolphy::Router

Inherits:
Object
  • Object
show all
Defined in:
lib/dolphy/router.rb

Constant Summary collapse

HTTP_METHODS =
i(get post put delete head options patch trace)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRouter

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

#routesObject

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