提交 605ab030 编写于 作者: A Aaron Patterson

push is_a check up to where the Constraints object is allocated

上级 b18f22d1
......@@ -16,7 +16,7 @@ def rack_app
@rack_app ||= begin
endpoint = app.app
if ActionDispatch::Routing::Redirect === endpoint || !app.dispatcher?
if app.redirect? || !app.dispatcher?
endpoint
end
end
......
......@@ -18,7 +18,7 @@ class Mapper
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 @@ def initialize(app, constraints, request, dispatcher_p)
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 @@ def normalize_conditions!
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册