Class: ModuleFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/module_finder.rb

Overview

Object in charge of finding a prefix

Class Method Summary collapse

Class Method Details

.dig(routes) ⇒ Object



6
7
8
# File 'lib/module_finder.rb', line 6

def dig(routes)
  find_scope_of_route(routes.instance_variable_get('@scope'))
end

.find_scope_of_route(route) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/module_finder.rb', line 10

def find_scope_of_route(route)
  found = route&.instance_variable_get('@hash')&.try(:[], :module)
  return found if found

  route = route.instance_variable_get('@parent')
  if route
    find_scope_of_route(route)
  else
    ''
  end
end