Class: Rosendo::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/rosendo/routes.rb

Defined Under Namespace

Classes: Route

Instance Method Summary collapse

Constructor Details

#initializeRoutes

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