Class: RailsDevtools::Routes::EngineInfo

Inherits:
Object
  • Object
show all
Defined in:
app/models/rails_devtools/routes/engine_info.rb

Instance Method Summary collapse

Constructor Details

#initialize(engine_name) ⇒ EngineInfo

Returns a new instance of EngineInfo.



4
5
6
# File 'app/models/rails_devtools/routes/engine_info.rb', line 4

def initialize(engine_name)
  @engine_name = engine_name
end

Instance Method Details

#engineObject



8
9
10
11
12
# File 'app/models/rails_devtools/routes/engine_info.rb', line 8

def engine
  return Rails.application if @engine_name == "Application"

  @engine_name.constantize
end

#engine?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/models/rails_devtools/routes/engine_info.rb', line 14

def engine?
  @engine_name != "Application"
end

#helper_prefixObject



26
27
28
29
30
# File 'app/models/rails_devtools/routes/engine_info.rb', line 26

def helper_prefix
  return "" unless engine?

  path.split("/").last.underscore
end

#nameObject



18
19
20
# File 'app/models/rails_devtools/routes/engine_info.rb', line 18

def name
  @engine_name
end

#pathObject



22
23
24
# File 'app/models/rails_devtools/routes/engine_info.rb', line 22

def path
  @path ||= engine.routes.find_script_name({})
end