Methods
- E
- N
- R
Included Modules
Attributes
| [RW] | eager_load | |
| [R] | external_routes | |
| [R] | paths | |
| [R] | route_sets |
Class Public methods
new(file_watcher: ActiveSupport::FileUpdateChecker) Link
# File railties/lib/rails/application/routes_reloader.rb, line 15 def initialize(file_watcher: ActiveSupport::FileUpdateChecker) @paths = [] @route_sets = [] @external_routes = [] @eager_load = false @load_state = nil # nil (not loaded yet) | :loading | :loaded @load_lock = Monitor.new @file_watcher = file_watcher end
Instance Public methods
execute() Link
execute_unless_loaded() Link
# File railties/lib/rails/application/routes_reloader.rb, line 42 def execute_unless_loaded return false if @load_state == :loaded @load_lock.synchronize do # Another thread finished the load while this one was blocked on # @load_lock. Return true so callers like # LazyRouteSet#method_missing retry the url helper that was # missing when they were called. return true if @load_state == :loaded # Drawing the routes re-enters this method on the same thread — # config/routes.rb itself calls routes.draw — through the # reentrant Monitor; without this check the nested call would # recurse into another draw. return false if @load_state == :loading execute ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application) @load_state = :loaded true end end
reload!() Link
# File railties/lib/rails/application/routes_reloader.rb, line 25 def reload! @load_lock.synchronize do previous_state, @load_state = @load_state, :loading clear! load_paths finalize! route_sets.each(&:eager_load!) if eager_load ensure @load_state = previous_state revert end end