aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-24 19:07:26 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-24 19:07:26 -0700
commitb6ec5e2c14e30bbb8a8dc434da36fc976440f2ca (patch)
tree2781d67c9617ae2381e2616dc99fcf66f26add27 /actionpack/lib
parent633589c1405990bde9ebd8cdde096f58c7e376bb (diff)
downloadrails-b6ec5e2c14e30bbb8a8dc434da36fc976440f2ca.tar.gz
rails-b6ec5e2c14e30bbb8a8dc434da36fc976440f2ca.tar.bz2
rails-b6ec5e2c14e30bbb8a8dc434da36fc976440f2ca.zip
eliminate dispatcher is_a checks
Diffstat (limited to 'actionpack/lib')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index c7f6ff620e..a6f17b9459 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)
+ def initialize(app, constraints, request, dispatcher_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,10 +28,7 @@ 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)
+ @dispatcher = dispatcher_p
@app, @constraints, @request = app, constraints, request
end
@@ -223,12 +220,21 @@ module ActionDispatch
end
def app
- endpoint = to.respond_to?(:call) ? to : dispatcher
+ # 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
+ else
+ dispatcher_p = true
+ endpoint = dispatcher
+ end
if blocks.any?
- Constraints.new(endpoint, blocks, @set.request_class)
+ Constraints.new(endpoint, blocks, @set.request_class, dispatcher_p)
else
- Constraints.new(endpoint, blocks, @set.request_class)
+ Constraints.new(endpoint, blocks, @set.request_class, dispatcher_p)
end
end