class ActionDispatch::Routing::Mapper::Constraints
:nodoc:
def self.new(app, constraints, request = Rack::Request)
def self.new(app, constraints, request = Rack::Request) if constraints.any? super(app, constraints, request) else app end end
def call(env)
def call(env) matches?(env) ? @app.call(env) : [ 404, {'X-Cascade' => 'pass'}, [] ] end
def constraint_args(constraint, request)
def constraint_args(constraint, request) constraint.arity == 1 ? [request] : [request.symbolized_path_parameters, request] end
def initialize(app, constraints, request)
def initialize(app, constraints, request) @app, @constraints, @request = app, constraints, request end
def matches?(env)
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 end