module Roda::RodaPlugins::AutoloadNamedRoutes::ClassMethods
def autoload_named_route(namespace=nil, name, file)
Autoload the given file when there is request for the named route.
def autoload_named_route(namespace=nil, name, file) file = File.expand_path(file) opts[:autoload_named_route_files] << file routes = opts[:namespaced_routes][namespace] ||= {} meth = routes[name] = define_roda_method(routes[name] || "named_routes_#{namespace}_#{name}", 1) do |r| loc = method(routes[name]).source_location require file # Avoid infinite loop in case method is not overridden if method(meth).source_location != loc send(meth, r) end end nil end