Permalink
Browse files

push is_a?(Dispatcher) check in to one place

  • Loading branch information...
1 parent 229c9ed commit 633589c1405990bde9ebd8cdde096f58c7e376bb @tenderlove tenderlove committed May 25, 2014
@@ -16,14 +16,6 @@ def initialize(name, app, path, constraints, defaults = {})
@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 @@ def glob?
end
def dispatcher?
- @dispatcher
+ @app.dispatcher?
end
def matches?(request)
@@ -28,9 +28,16 @@ def initialize(app, constraints, request)
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)
@@ -703,12 +703,10 @@ def recognize_path(path, environment = {})
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
@@ -9,6 +9,7 @@ class StubDispatcher < Routing::RouteSet::Dispatcher
def initialize
super({})
end
+ def dispatcher?; true; end
end
attr_reader :routes

0 comments on commit 633589c

Please sign in to comment.