• S
    Fixing an edge case when using objects as constraints · d043920e
    Simon Courtois 提交于
    This PR fixes an issue when the following situation occurs.
    If you define a class like this
    
        class MyConstraint
          def call(*args)
            # for some reason this is defined
          end
    
          def matches?(*args)
            # checking the args
          end
        end
    
    and try to use it as a constraint
    
        get "/", to: "home#show", constraints: MyConstraint.new
    
    if its `matches?` method returns `false` there will be an error for the
    mapper will ask for the constraint arity, thinking it is a proc, lambda
    or method.
    
    This PR checks for the presence of the `arity` method on the constraint
    calling it only if present, preventing the error while keeping the basic
    behavior.
    d043920e
routing_test.rb 141.0 KB