Module: MissionControl::Jobs::Theme::RouteDiscovery
- Defined in:
- lib/mission_control/jobs/theme/route_discovery.rb
Overview
Detect where Engine is mounted by inspecting the Rails route table at boot time.
Falls back to FALLBACK when the engine is not loaded or no matching route is found.
Constant Summary collapse
- FALLBACK =
"/jobs"
Class Method Summary collapse
-
.discover(routes) ⇒ String
Inspect the application route set for a mounted Mission Control Jobs engine and return its path prefix.
Class Method Details
.discover(routes) ⇒ String
Inspect the application route set for a mounted Mission Control Jobs engine and return its path prefix.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/mission_control/jobs/theme/route_discovery.rb', line 24 def self.discover(routes) engine = defined?(MissionControl::Jobs::Engine) ? MissionControl::Jobs::Engine : nil return FALLBACK unless engine routes.routes.each do |route| mounted_app = route.app&.app next unless mounted_app == engine return route.path.spec.to_s.chomp("(.:format)").delete_suffix("/") rescue NoMethodError next end FALLBACK end |