diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-24 17:52:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-05-24 17:52:22 -0700 |
commit | 98c7fe87690ca4de6c46e8f69806e82e3f8af42d (patch) | |
tree | f7b49029582af9f6b9e631989038131a30eab7ce /actionpack/lib/action_dispatch/routing | |
parent | 107c27bb2154bc754ae8b26453460466cd6312e4 (diff) | |
download | rails-98c7fe87690ca4de6c46e8f69806e82e3f8af42d.tar.gz rails-98c7fe87690ca4de6c46e8f69806e82e3f8af42d.tar.bz2 rails-98c7fe87690ca4de6c46e8f69806e82e3f8af42d.zip |
unwrap the constraints object on initialization, eliminate loops
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
*think* they were just being defensive, but I have no idea.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/inspector.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 9 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 |
3 files changed, 11 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/routing/inspector.rb b/actionpack/lib/action_dispatch/routing/inspector.rb index 71a0c5e826..2135b280da 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 class_name = app.class.name.to_s if class_name == "ActionDispatch::Routing::Mapper::Constraints" - rack_app(app.app) + app.app elsif ActionDispatch::Routing::Redirect === app || class_name !~ /^ActionDispatch::Routing/ app end diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index f39fd1ea35..b33c5e0dfd 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -19,6 +19,15 @@ module ActionDispatch attr_reader :app, :constraints def initialize(app, constraints, request) + # 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 + # *think* they were just being defensive, but I have no idea. + while app.is_a?(self.class) + constraints += app.constraints + app = app.app + end + @app, @constraints, @request = app, constraints, request end diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 40c767e685..924455bce2 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -704,7 +704,7 @@ module ActionDispatch old_params = req.path_parameters req.path_parameters = old_params.merge params dispatcher = route.app - while dispatcher.is_a?(Mapper::Constraints) && dispatcher.matches?(env) do + if dispatcher.is_a?(Mapper::Constraints) && dispatcher.matches?(env) dispatcher = dispatcher.app end |