Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #8715 from goshakkk/refactor-mapper

Refactor Routing::Mapper#matches?
  • Loading branch information...
commit e0be37ccdb73a11035d3cff640bdfde7d4986cfc 2 parents fe649b1 + 77f2ba9
@carlosantoniodasilva carlosantoniodasilva authored
Showing with 4 additions and 9 deletions.
  1. +4 −9 actionpack/lib/action_dispatch/routing/mapper.rb
View
13 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -26,15 +26,10 @@ def initialize(app, constraints, request)
def matches?(env)
req = @request.new(env)
- @constraints.each { |constraint|
- if constraint.respond_to?(:matches?) && !constraint.matches?(req)
- return false
- elsif constraint.respond_to?(:call) && !constraint.call(*constraint_args(constraint, req))
- return false
- end
- }
-
- return true
+ @constraints.none? do |constraint|
+ (constraint.respond_to?(:matches?) && !constraint.matches?(req)) ||
+ (constraint.respond_to?(:call) && !constraint.call(*constraint_args(constraint, req)))
+ end
ensure
req.reset_parameters
end
Please sign in to comment.
Something went wrong with that request. Please try again.