Class: Rails::Engine::LazyRouteSet

Inherits:
ActionDispatch::Routing::RouteSet show all
Defined in:
railties/lib/rails/engine/lazy_route_set.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ProxyUrlHelpers Classes: NamedRouteCollection

Constant Summary

Constants inherited from ActionDispatch::Routing::RouteSet

ActionDispatch::Routing::RouteSet::DEFAULT_CONFIG, ActionDispatch::Routing::RouteSet::PATH, ActionDispatch::Routing::RouteSet::RESERVED_OPTIONS, ActionDispatch::Routing::RouteSet::UNKNOWN

Instance Attribute Summary

Attributes inherited from ActionDispatch::Routing::RouteSet

#default_url_options, #disable_clear_and_finalize, #draw_paths, #env_key, #formatter, #named_routes, #polymorphic_mappings, #resources_path_names, #router, #set

Instance Method Summary collapse

Methods inherited from ActionDispatch::Routing::RouteSet

#add_polymorphic_mapping, #add_route, #add_url_helper, #api_only?, #append, #clear!, #default_env, default_resources_path_names, #default_scope, #default_scope=, #define_mounted_helper, #eager_load!, #empty?, #extra_keys, #finalize!, #find_script_name, #from_requirements, #mounted_helpers, new_with_config, #optimize_routes_generation?, #path_for, #prepend, #relative_url_root, #request_class, #url_for, #url_helpers

Constructor Details

#initialize(config = DEFAULT_CONFIG) ⇒ LazyRouteSet

Returns a new instance of LazyRouteSet.



49
50
51
52
53
54
# 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) ⇒ Object



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

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

#draw(&block) ⇒ Object



71
72
73
74
# 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 = {}) ⇒ Object



56
57
58
59
60
# 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) ⇒ Object



62
63
64
# 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

#recognize_path(path, environment = {}) ⇒ Object



76
77
78
79
# 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_requestObject



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

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

#routesObject



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

def routes
  Rails.application&.reload_routes_unless_loaded
  super
end