aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-26 13:20:43 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-26 13:20:43 -0700
commit605ab030a9a8fd8ce77ee20ab246875f958c551f (patch)
treee0c2d27dbf9e74d0405b8c4ef735ac3061bda09c /actionpack/lib
parentb18f22d15c28fc5fe634928d59148c932bba4696 (diff)
downloadrails-605ab030a9a8fd8ce77ee20ab246875f958c551f.tar.gz
rails-605ab030a9a8fd8ce77ee20ab246875f958c551f.tar.bz2
rails-605ab030a9a8fd8ce77ee20ab246875f958c551f.zip
push is_a check up to where the Constraints object is allocated
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/routing/inspector.rb2
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb15
2 files changed, 11 insertions, 6 deletions
diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb
index 273f5b9306..dc03a7370e 100644
--- a/actionpack/lib/action_dispatch/routing/inspector.rb
+++ b/actionpack/lib/action_dispatch/routing/inspector.rb
@@ -16,7 +16,7 @@ module ActionDispatch
@rack_app ||= begin
endpoint = app.app
- if ActionDispatch::Routing::Redirect === endpoint || !app.dispatcher?
+ if app.redirect? || !app.dispatcher?
endpoint
end
end
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 08a5e7c637..86357ded4f 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -18,7 +18,7 @@ module ActionDispatch
class Constraints #:nodoc:
attr_reader :app, :constraints
- def initialize(app, constraints, request, dispatcher_p)
+ def initialize(app, constraints, request, dispatcher_p, redirect_p)
# Unwrap Constraints objects. I don't actually think it's possible
# to pass a Constraints object to this constructor, but there were
# multiple places that kept testing children of this object. I
@@ -28,12 +28,14 @@ module ActionDispatch
app = app.app
end
- @dispatcher = dispatcher_p
+ @dispatcher = dispatcher_p
+ @redirect = redirect_p
@app, @constraints, @request = app, constraints, request
end
def dispatcher?; @dispatcher; end
+ def redirect?; @redirect; end
def matches?(req)
@constraints.all? do |constraint|
@@ -218,21 +220,24 @@ module ActionDispatch
end
def app
+ dispatcher_p = false
+ redirect = false
+
# 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 to.respond_to?(:call)
- dispatcher_p = false
endpoint = to
+ redirect = Redirect === endpoint
else
dispatcher_p = true
endpoint = dispatcher
end
if blocks.any?
- Constraints.new(endpoint, blocks, @set.request_class, dispatcher_p)
+ Constraints.new(endpoint, blocks, @set.request_class, dispatcher_p, redirect)
else
- Constraints.new(endpoint, blocks, @set.request_class, dispatcher_p)
+ Constraints.new(endpoint, blocks, @set.request_class, dispatcher_p, redirect)
end
end