123456789_123456789_123456789_123456789_123456789_

Class: Rails::Engine::LazyRouteSet

Do not use. This class is for internal use only.
Relationships & Source Files
Namespace Children
Modules:
Classes:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
Inherits: ActionDispatch::Routing::RouteSet
Defined in: railties/lib/rails/engine/lazy_route_set.rb

Constant Summary

::ActionDispatch::Routing::RouteSet - Inherited

DEFAULT_CONFIG, PATH, RESERVED_OPTIONS, UNKNOWN

Class Method Summary

Instance Attribute Summary

Instance Method Summary

::ActionDispatch::Routing::RouteSet - Inherited

#from_requirements

Returns a Route matching the given requirements, or nil if none are found.

#add_polymorphic_mapping, #add_route, #add_url_helper, #append, #call, #clear!, #default_env, #define_mounted_helper, #draw, #eager_load!,
#extra_keys

Generate the path indicated by the arguments, and return an array of the keys that were not used to generate it.

#finalize!, #find_script_name, #generate_extras, #generate_url_helpers,
#inspect

Since the router holds references to many parts of the system like engines, controllers and the application itself, inspecting the route set can actually be really slow, therefore we default alias inspect to to_s.

#mounted_helpers

Contains all the mounted helpers across different engines and the main_app helper for the application.

#path_for, #prepend, #recognize_path, #recognize_path_with_request, #relative_url_root, #request_class,
#url_for

The options argument must be a hash whose keys are symbols.

#url_helpers, #eval_block, #generate, #make_request

Constructor Details

.new(config = DEFAULT_CONFIG) ⇒ LazyRouteSet

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 49

def initialize(config = DEFAULT_CONFIG)
  super
  self.named_routes = NamedRouteCollection.new
  named_routes.url_helpers_module.prepend(method_missing_module)
  named_routes.path_helpers_module.prepend(method_missing_module)
end

Instance Method Details

#call(req)

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 66

def call(req)
  Rails.application&.reload_routes_unless_loaded
  super
end

#draw(&block)

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 71

def draw(&block)
  Rails.application&.reload_routes_unless_loaded
  super
end

#generate_extras(options, recall = {})

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 56

def generate_extras(options, recall = {})
  Rails.application&.reload_routes_unless_loaded

  super(options, recall)
end

#generate_url_helpers(supports_path)

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 62

def generate_url_helpers(supports_path)
  super.tap { |mod| mod.singleton_class.prepend(ProxyUrlHelpers) }
end

#method_missing_module (private)

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 92

def method_missing_module
  @method_missing_module ||= Module.new do
    private
      def method_missing(...)
        if Rails.application&.reload_routes_unless_loaded
          public_send(...)
        else
          super
        end
      end

      def respond_to_missing?(...)
        if Rails.application&.reload_routes_unless_loaded
          respond_to?(...)
        else
          super
        end
      end
  end
end

#recognize_path(path, environment = {})

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 76

def recognize_path(path, environment = {})
  Rails.application&.reload_routes_unless_loaded
  super
end

#recognize_path_with_request

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 81

def recognize_path_with_request(...)
  Rails.application&.reload_routes_unless_loaded
  super
end

#routes

[ GitHub ]

  
# File 'railties/lib/rails/engine/lazy_route_set.rb', line 86

def routes
  Rails.application&.reload_routes_unless_loaded
  super
end