class ActionDispatch::Routing::Mapper::Constraints

:nodoc:

def constraint_args(constraint, request)

def constraint_args(constraint, request)
  arity = if constraint.respond_to?(:arity)
    constraint.arity
  else
    constraint.method(:call).arity
  end
  if arity < 1
    []
  elsif arity == 1
    [request]
  else
    [request.path_parameters, request]
  end
end

def dispatcher?; @strategy == SERVE; end

def dispatcher?; @strategy == SERVE; end

def initialize(app, constraints, strategy)

def initialize(app, constraints, strategy)
  # 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.
  if app.is_a?(self.class)
    constraints += app.constraints
    app = app.app
  end
  @strategy = strategy
  @app, @constraints, = app, constraints
end

def matches?(req)

def matches?(req)
  @constraints.all? do |constraint|
    (constraint.respond_to?(:matches?) && constraint.matches?(req)) ||
      (constraint.respond_to?(:call) && constraint.call(*constraint_args(constraint, req)))
  end
end

def serve(req)

def serve(req)
  return [ 404, { Constants::X_CASCADE => "pass" }, [] ] unless matches?(req)
  @strategy.call @app, req
end