diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-24 19:03:12 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-24 19:03:12 -0700 |
commit | 633589c1405990bde9ebd8cdde096f58c7e376bb (patch) | |
tree | 29d28b2f2f5b756ea9776231ed66590fde09f5b6 /actionpack/lib | |
parent | 229c9ed89658cabd74764b7f5a2509bee33d364c (diff) | |
download | rails-633589c1405990bde9ebd8cdde096f58c7e376bb.tar.gz rails-633589c1405990bde9ebd8cdde096f58c7e376bb.tar.bz2 rails-633589c1405990bde9ebd8cdde096f58c7e376bb.zip |
push is_a?(Dispatcher) check in to one place
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/journey/route.rb | 10 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 7 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 8 |
3 files changed, 11 insertions, 14 deletions
diff --git a/actionpack/lib/action_dispatch/journey/route.rb b/actionpack/lib/action_dispatch/journey/route.rb index 1ba91d548e..9f0a3af902 100644 --- a/actionpack/lib/action_dispatch/journey/route.rb +++ b/actionpack/lib/action_dispatch/journey/route.rb @@ -16,14 +16,6 @@ module ActionDispatch @app = app @path = path - # Unwrap any constraints so we can see what's inside for route generation. - # This allows the formatter to skip over any mounted applications or redirects - # that shouldn't be matched when using a url_for without a route name. - if app.is_a?(Routing::Mapper::Constraints) - app = app.app - end - @dispatcher = app.is_a?(Routing::RouteSet::Dispatcher) - @constraints = constraints @defaults = defaults @required_defaults = nil @@ -99,7 +91,7 @@ module ActionDispatch end def dispatcher? - @dispatcher + @app.dispatcher? end def matches?(request) diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index c5e093dae5..c7f6ff620e 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -28,9 +28,16 @@ module ActionDispatch app = app.app end + # Unwrap any constraints so we can see what's inside for route generation. + # This allows the formatter to skip over any mounted applications or redirects + # that shouldn't be matched when using a url_for without a route name. + @dispatcher = app.is_a?(Routing::RouteSet::Dispatcher) + @app, @constraints, @request = app, constraints, request end + def dispatcher?; @dispatcher; end + def matches?(env) req = @request.new(env) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index f36453020f..5839db87f9 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -703,12 +703,10 @@ module ActionDispatch end old_params = req.path_parameters req.path_parameters = old_params.merge params - dispatcher = route.app - if dispatcher.matches?(env) - dispatcher = dispatcher.app - end + app = route.app + if app.matches?(env) && app.dispatcher? + dispatcher = app.app - if dispatcher.is_a?(Dispatcher) if dispatcher.controller(params, false) dispatcher.prepare_params!(params) return params |