Class: Wallaby::EngineNameFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/services/wallaby/engine_name_finder.rb

Overview

Find out the engine routing proxy name

Class Method Summary collapse

Class Method Details

.execute(request_path) ⇒ String

Go through all the routes and find out the engine routing proxy name for the given request path.

When it can’t find the engine name, it will return empty string to prevent it from being run again.

Parameters:

  • request_path (String)

    request path

Returns:

  • (String)

    engine name if found

  • (String)

    empty string “” if not found



15
16
17
18
19
20
21
22
# File 'lib/services/wallaby/engine_name_finder.rb', line 15

def execute(request_path)
  named_routes =
    Rails.application.routes.routes.find do |route|
      route.path.match(request_path) && route.app.app == Wallaby::Engine
    end

  named_routes.try(:name) || EMPTY_STRING
end