lib/hanami/routing/routes_inspector.rb in hanami-router-0.7.0 vs lib/hanami/routing/routes_inspector.rb in hanami-router-0.8.0
- old
+ new
@@ -45,12 +45,13 @@
#
# @return [Hanami::Routing::RoutesInspector] the new instance
#
# @since 0.2.0
# @api private
- def initialize(routes)
+ def initialize(routes, prefix)
@routes = routes
+ @prefix = prefix
end
# Return a formatted string that describes all the routes
#
# @param formatter [String] the optional formatter for a route
@@ -131,11 +132,11 @@
#
# | GET, HEAD | | /fakeroute | Fake::Index |
# | GET, HEAD | | /admin/home | Home::Index |
# | GET, HEAD | | /api/posts | Posts::Index |
# | GET, HEAD | | /api/second_mount/comments | Comments::Index |
- def to_s(formatter = FORMATTER, base_path = nil)
+ def to_s(formatter = FORMATTER, base_path = prefix)
base_path = Utils::PathPrefix.new(base_path)
inspect_routes(formatter, base_path)
.insert(0, formatter % INSPECTOR_HEADER_HASH + EMPTY_LINE)
end
@@ -168,9 +169,13 @@
result
end
private
+
+ # @since 0.8.0
+ # @api private
+ attr_reader :prefix
# Returns a string representation of the given route
#
# @param formatter [String] the template for the output
# @param route [Hanami::Routing::Route] a route