Class: Rails::Application::RoutesReloader

Inherits:
Object
  • Object
show all
Includes:
ActiveSupport::Callbacks
Defined in:
lib/rails/application/routes_reloader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRoutesReloader

Returns a new instance of RoutesReloader.



15
16
17
18
19
20
21
# File 'lib/rails/application/routes_reloader.rb', line 15

def initialize
  @paths      = []
  @route_sets = []
  @external_routes = []
  @eager_load = false
  @loaded = false
end

Instance Attribute Details

#eager_loadObject

Returns the value of attribute eager_load.



11
12
13
# File 'lib/rails/application/routes_reloader.rb', line 11

def eager_load
  @eager_load
end

#external_routesObject (readonly)

Returns the value of attribute external_routes.



10
11
12
# File 'lib/rails/application/routes_reloader.rb', line 10

def external_routes
  @external_routes
end

#loadedObject (readonly)

Returns the value of attribute loaded.



10
11
12
# File 'lib/rails/application/routes_reloader.rb', line 10

def loaded
  @loaded
end

#pathsObject (readonly)

Returns the value of attribute paths.



10
11
12
# File 'lib/rails/application/routes_reloader.rb', line 10

def paths
  @paths
end

#route_setsObject (readonly)

Returns the value of attribute route_sets.



10
11
12
# File 'lib/rails/application/routes_reloader.rb', line 10

def route_sets
  @route_sets
end

#run_after_load_paths=(value) ⇒ Object

:nodoc:



12
13
14
# File 'lib/rails/application/routes_reloader.rb', line 12

def run_after_load_paths=(value)
  @run_after_load_paths = value
end

Instance Method Details

#executeObject



32
33
34
35
# File 'lib/rails/application/routes_reloader.rb', line 32

def execute
  @loaded = true
  updater.execute
end

#execute_unless_loadedObject



37
38
39
40
41
42
43
# File 'lib/rails/application/routes_reloader.rb', line 37

def execute_unless_loaded
  unless @loaded
    execute
    ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application)
    true
  end
end

#reload!Object



23
24
25
26
27
28
29
30
# File 'lib/rails/application/routes_reloader.rb', line 23

def reload!
  clear!
  load_paths
  finalize!
  route_sets.each(&:eager_load!) if eager_load
ensure
  revert
end