lib/chusaku/routes.rb in chusaku-1.2.0 vs lib/chusaku/routes.rb in chusaku-1.3.0
- old
+ new
@@ -25,11 +25,23 @@
#
# @return [Hash] Routes hash
def call
routes = {}
- Rails.application.routes.routes.each do |route|
+ populate_routes(Rails.application, routes)
+ backfill_routes(routes)
+ end
+
+ private
+
+ def populate_routes(app, routes)
+ app.routes.routes.each do |route|
+ if route.app.engine?
+ populate_routes(route.app.app, routes)
+ next
+ end
+
controller, action, defaults = extract_data_from(route)
routes[controller] ||= {}
routes[controller][action] ||= []
add_info_for \
@@ -37,14 +49,10 @@
routes: routes,
controller: controller,
action: action,
defaults: defaults
end
-
- backfill_routes(routes)
end
-
- private
# Adds formatted route info for the given param combination.
#
# @param route [Hash] Route info
# @param routes [Hash] Collection of all route info