instance method execute_unless_loaded

Ruby on Rails edge

Since v8.0.5.1

Available in: v8.0.5.1 v8.1.3.1 edge

Signature

execute_unless_loaded()

No documentation comment.

Source
# File railties/lib/rails/application/routes_reloader.rb, line 50
      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

          # Hold :loading across after_routes_loaded as well. reload! restores
          # the previous state when it finishes, so if we left that as nil a
          # hook that touched routes would re-enter and draw again.
          @load_state = :loading
          begin
            execute
            ActiveSupport.run_load_hooks(:after_routes_loaded, Rails.application)
            @load_state = :loaded
            true
          ensure
            @load_state = nil if @load_state == :loading
          end
        end
      end

Defined in railties/lib/rails/application/routes_reloader.rb line 50 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Application::RoutesReloader

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close