Refactor Routing::Mapper#matches? #8715

Merged
merged 1 commit into from Jan 3, 2013

Projects

None yet

4 participants

@goshakkk
Contributor
goshakkk commented Jan 3, 2013

No description provided.

@utkarshkukreti utkarshkukreti and 1 other commented on an outdated diff Jan 3, 2013
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.any? do |constraint|
@utkarshkukreti
utkarshkukreti Jan 3, 2013 Contributor

Could just use .none? instead of !...any?.

@goshakkk
goshakkk Jan 3, 2013 Contributor

Nice catch, fixed, thanks.

@carlosantoniodasilva carlosantoniodasilva merged commit e0be37c into rails:master Jan 3, 2013
@goshakkk goshakkk deleted the goshakkk:refactor-mapper branch Jan 3, 2013
@batiste
batiste commented on 77f2ba9 Jun 2, 2015

This commit changed the behaviour somehow. We use to have nil constraints that returned true (a config) and now with this nil returns false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment