Module: Roda::RodaPlugins::MultiRoute::RequestMethods
- Defined in:
- lib/roda/plugins/multi_route.rb
Instance Method Summary collapse
-
#multi_route(namespace = nil) ⇒ Object
Check if the first segment in the path matches any of the current named routes.
-
#route(name, namespace = nil) ⇒ Object
Dispatch to the named route with the given name.
Instance Method Details
#multi_route(namespace = nil) ⇒ Object
Check if the first segment in the path matches any of the current named routes. If so, call that named route. If not, do nothing. If the named route does not handle the request, and a block is given, yield to the block.
207 208 209 210 211 212 213 214 215 216 |
# File 'lib/roda/plugins/multi_route.rb', line 207 def multi_route(namespace=nil) on self.class.named_route_regexp(namespace) do |section| r = route(section, namespace) if block_given? yield else r end end end |
#route(name, namespace = nil) ⇒ Object
Dispatch to the named route with the given name.
219 220 221 |
# File 'lib/roda/plugins/multi_route.rb', line 219 def route(name, namespace=nil) scope.send(roda_class.named_route(name, namespace), self) end |