aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/routing/route_set.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/route_set.rb')
-rw-r--r--actionpack/lib/action_dispatch/routing/route_set.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb
index 6d964c2cbf..0f3734dd74 100644
--- a/actionpack/lib/action_dispatch/routing/route_set.rb
+++ b/actionpack/lib/action_dispatch/routing/route_set.rb
@@ -20,8 +20,6 @@ module ActionDispatch
# alias inspect to to_s.
alias inspect to_s
- mattr_accessor :relative_url_root
-
class Dispatcher < Routing::Endpoint
def initialize(defaults)
@defaults = defaults
@@ -320,11 +318,25 @@ module ActionDispatch
{ :new => 'new', :edit => 'edit' }
end
- def initialize
+ def self.new_with_config(config)
+ if config.respond_to? :relative_url_root
+ new Config.new config.relative_url_root
+ else
+ # engines apparently don't have this set
+ new
+ end
+ end
+
+ Config = Struct.new :relative_url_root
+
+ DEFAULT_CONFIG = Config.new(nil)
+
+ def initialize(config = DEFAULT_CONFIG)
self.named_routes = NamedRouteCollection.new
self.resources_path_names = self.class.default_resources_path_names
self.default_url_options = {}
+ @config = config
@append = []
@prepend = []
@disable_clear_and_finalize = false
@@ -336,6 +348,10 @@ module ActionDispatch
@formatter = Journey::Formatter.new @set
end
+ def relative_url_root
+ @config.relative_url_root
+ end
+
def request_class
ActionDispatch::Request
end