Class: SimpleRouter::Routes
- Inherits:
-
Array
- Object
- Array
- SimpleRouter::Routes
- Defined in:
- lib/simple_router/routes.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Route
Instance Attribute Summary collapse
-
#engine ⇒ Object
routing engine.
Instance Method Summary collapse
Instance Attribute Details
#engine ⇒ Object
routing engine
5 6 7 |
# File 'lib/simple_router/routes.rb', line 5 def engine @engine end |
Instance Method Details
#add(*args, &action) ⇒ Object
11 12 13 |
# File 'lib/simple_router/routes.rb', line 11 def add(*args, &action) self << Route.new(*args, &action) end |
#match(verb, path) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/simple_router/routes.rb', line 15 def match(verb, path) unless self.empty? routes = self.select {|route| route.verb == verb } paths = routes.map {|route| route.path } path = self.engine.match(path, paths) routes.detect {|route| route.path == path } end end |