Class: Rosendo::Routes
- Inherits:
-
Object
- Object
- Rosendo::Routes
- Defined in:
- lib/rosendo/routes.rb
Defined Under Namespace
Classes: Route
Instance Method Summary collapse
- #<<(route) ⇒ Object
- #add(method, path, &block) ⇒ Object
- #for(request) ⇒ Object
-
#initialize ⇒ Routes
constructor
A new instance of Routes.
Constructor Details
#initialize ⇒ Routes
Returns a new instance of Routes.
3 4 5 |
# File 'lib/rosendo/routes.rb', line 3 def initialize @routes = [] end |
Instance Method Details
#<<(route) ⇒ Object
7 8 9 |
# File 'lib/rosendo/routes.rb', line 7 def <<(route) @routes << route end |
#add(method, path, &block) ⇒ Object
15 16 17 |
# File 'lib/rosendo/routes.rb', line 15 def add(method, path, &block) self << Route.new(method, path, &block) end |
#for(request) ⇒ Object
11 12 13 |
# File 'lib/rosendo/routes.rb', line 11 def for(request) @routes.detect { |route| route.matches?(request) } end |