Class: Lotus::Routing::RoutesInspector
- Inherits:
-
Object
- Object
- Lotus::Routing::RoutesInspector
- Defined in:
- lib/lotus/routing/routes_inspector.rb
Overview
Routes inspector
Constant Summary collapse
- FORMATTER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default route formatter
"%<name>20s %<methods>-10s %<path>-30s %<endpoint>-30s\n".freeze
- HTTP_METHODS_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Default HTTP methods separator
', '.freeze
Instance Method Summary collapse
-
#initialize(routes) ⇒ Lotus::Routing::RoutesInspector
constructor
private
Instantiate a new inspector.
-
#to_s(formatter = FORMATTER, base_path = nil) ⇒ String
Return a formatted string that describes all the routes.
Constructor Details
#initialize(routes) ⇒ Lotus::Routing::RoutesInspector
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Instantiate a new inspector
27 28 29 |
# File 'lib/lotus/routing/routes_inspector.rb', line 27 def initialize(routes) @routes = routes end |
Instance Method Details
#to_s(formatter = FORMATTER, base_path = nil) ⇒ String
Return a formatted string that describes all the routes
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/lotus/routing/routes_inspector.rb', line 107 def to_s(formatter = FORMATTER, base_path = nil) base_path = Utils::PathPrefix.new(base_path) result = '' # TODO refactoring: replace conditional with polymorphism # We're exposing too much knowledge from Routing::Route: # #path_for_generation and #base_path @routes.each do |route| result << if router = route.nested_router inspect_router(formatter, router, route, base_path) else inspect_route(formatter, route, base_path) end end result end |