module Roda::RodaPlugins::MultiRoute::ClassMethods
def freeze
def freeze opts[:namespaced_routes].freeze.each do |k,v| v.freeze self::RodaRequest.named_route_regexp(k) end self::RodaRequest.instance_variable_get(:@namespaced_route_regexps).freeze super end
def inherited(subclass)
def inherited(subclass) super nsr = subclass.opts[:namespaced_routes] opts[:namespaced_routes].each{|k, v| nsr[k] = v.dup} subclass::RodaRequest.instance_variable_set(:@namespaced_route_regexps, {}) end
def named_route(name, namespace=nil)
def named_route(name, namespace=nil) opts[:namespaced_routes][namespace][name] end
def named_routes(namespace=nil)
def named_routes(namespace=nil) unless routes = opts[:namespaced_routes][namespace] raise RodaError, "unsupported multi_route namespace used: #{namespace.inspect}" end routes.keys end
def route(name=nil, namespace=nil, &block)
store the route block. Otherwise, this is the main route, so
If the given route has a name, treat it as a named route and
def route(name=nil, namespace=nil, &block) if name opts[:namespaced_routes][namespace] ||= {} opts[:namespaced_routes][namespace][name] = block self::RodaRequest.clear_named_route_regexp!(namespace) else super(&block) end end