module Roda::RodaPlugins::AutoloadNamedRoutes::ClassMethods
Public Instance Methods
Source
# File lib/roda/plugins/autoload_named_routes.rb, line 40 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
Autoload the given file when there is request for the named route. The given file should configure the named route specified.
Source
# File lib/roda/plugins/autoload_named_routes.rb, line 56 def freeze opts.delete(:autoload_named_route_files).each{|file| require file} unless opts.frozen? super end
Eagerly load all autoloaded named routes when freezing the application.
Calls superclass method