Permalink
Browse files

Merge pull request #8715 from goshakkk/refactor-mapper

Refactor Routing::Mapper#matches?
  • Loading branch information...
2 parents fe649b1 + 77f2ba9 commit e0be37ccdb73a11035d3cff640bdfde7d4986cfc @carlosantoniodasilva carlosantoniodasilva committed Jan 3, 2013
Showing with 4 additions and 9 deletions.
  1. +4 −9 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

0 comments on commit e0be37c

Please sign in to comment.