Class: Decidim::EngineResolver

Inherits:
Object
  • Object
show all
Defined in:
app/services/decidim/engine_resolver.rb

Overview

This class can be used to resolve the mounted route based on the current routes in any provided context.

Instance Method Summary collapse

Constructor Details

#initialize(current_routes) ⇒ EngineResolver

Initializes the engine resolver instance.

Parameters:

  • current_routes (ActionDispatch::Routing::RouteSet)

    the route set for the context



11
12
13
# File 'app/services/decidim/engine_resolver.rb', line 11

def initialize(current_routes)
  @current_routes = current_routes
end

Instance Method Details

#mounted_nameString

Resolves the mounted route name for the provided context.

Returns:

  • (String)

    The resolved route name or “decidim” if it could not be resolved



19
20
21
22
23
24
# File 'app/services/decidim/engine_resolver.rb', line 19

def mounted_name
  return "main_app" if base_engine.routes == current_routes

  route = find_mounted_route(base_engine)
  route&.name || "decidim"
end