class Rage::Router::HandlerStorage

def add_handler(constrainer, route)

def add_handler(constrainer, route)
  params = route[:params]
  constraints = route[:constraints]
  handler_object = {
    params: params,
    constraints: constraints,
    handler: route[:handler],
    create_params_object: compile_create_params_object(params, route[:defaults], route[:meta])
  }
  constraints_keys = constraints.keys
  if constraints_keys.empty?
    @unconstrained_handler = handler_object
  end
  constraints_keys.each do |constraint_key|
    @constraints << constraint_key unless @constraints.include?(constraint_key)
  end
  if @handlers.length >= 32
    raise ArgumentError, "Limit reached: a maximum of 32 route handlers per node allowed when there are constraints"
  end
  @handlers << handler_object
  # Sort the most constrained handlers to the front of the list of handlers so they are tested first.
  @handlers.sort_by! { |a| a[:constraints].length }
  compile_get_handler_matching_constraints(constrainer)
end