class ActionDispatch::Routing::RoutesInspector
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/action_dispatch/routing/inspector.rbs class ActionDispatch::Routing::RoutesInspector def collect_engine_routes: (ActionDispatch::Routing::RouteWrapper route) -> nil end
:nodoc:
People should not use this class.
executes ‘bin/rails routes` or looks at the RoutingError page.
This class is just used for displaying route information when someone
#
def collect_engine_routes(route)
Experimental RBS support (using type sampling data from the type_fusion
project).
def collect_engine_routes: (ActionDispatch::Routing::RouteWrapper route) -> nil
This signature was generated using 3 samples from 1 application.
def collect_engine_routes(route) name = route.endpoint return unless route.engine? return if @engines[name] routes = route.rack_app.routes if routes.is_a?(ActionDispatch::Routing::RouteSet) @engines[name] = collect_routes(routes.routes) end end
def collect_routes(routes)
def collect_routes(routes) routes.collect do |route| RouteWrapper.new(route) end.reject(&:internal?).collect do |route| collect_engine_routes(route) { name: route.name, verb: route.verb, path: route.path, reqs: route.reqs } end end
def filter_routes(filter)
def filter_routes(filter) if filter @routes.select do |route| route_wrapper = RouteWrapper.new(route) filter.any? { |default, value| value.match?(route_wrapper.send(default)) } end else @routes end end
def format(formatter, filter = {})
def format(formatter, filter = {}) routes_to_display = filter_routes(normalize_filter(filter)) routes = collect_routes(routes_to_display) if routes.none? formatter.no_routes(collect_routes(@routes), filter) return formatter.result end formatter.header routes formatter.section routes @engines.each do |name, engine_routes| formatter.section_title "Routes for #{name}" formatter.section engine_routes end formatter.result end
def initialize(routes)
People should not use this class.
executes `bin/rails routes` or looks at the RoutingError page.
This class is just used for displaying route information when someone
#
def initialize(routes) @engines = {} @routes = routes end
def normalize_filter(filter)
def normalize_filter(filter) if filter[:controller] { controller: /#{filter[:controller].underscore.sub(/_?controller\z/, "")}/ } elsif filter[:grep] { controller: /#{filter[:grep]}/, action: /#{filter[:grep]}/, verb: /#{filter[:grep]}/, name: /#{filter[:grep]}/, path: /#{filter[:grep]}/ } end end