Module: Roda::RodaPlugins::MultiRoute::RequestClassMethods
- Defined in:
- lib/roda/plugins/multi_route.rb
Instance Method Summary collapse
-
#clear_named_route_regexp!(namespace = nil) ⇒ Object
Clear cached regexp for named routes, it will be regenerated the next time it is needed.
-
#named_route_regexp(namespace = nil) ⇒ Object
A regexp matching any of the current named routes.
Instance Method Details
#clear_named_route_regexp!(namespace = nil) ⇒ Object
Clear cached regexp for named routes, it will be regenerated the next time it is needed.
This shouldn’t be an issue in production applications, but during development it’s useful to support new named routes being added while the application is running.
126 127 128 |
# File 'lib/roda/plugins/multi_route.rb', line 126 def clear_named_route_regexp!(namespace=nil) @namespaced_route_regexps.delete(namespace) end |
#named_route_regexp(namespace = nil) ⇒ Object
A regexp matching any of the current named routes.
131 132 133 |
# File 'lib/roda/plugins/multi_route.rb', line 131 def named_route_regexp(namespace=nil) @namespaced_route_regexps[namespace] ||= /(#{Regexp.union(roda_class.named_routes(namespace).select{|s| s.is_a?(String)}.sort.reverse)})/ end |