class ActionDispatch::MiddlewareStack

def delete(target)

returns nil if the target is not found.
Returns the array of middlewares not including the deleted item, or

Deletes a middleware from the middleware stack.
def delete(target)
  middlewares.reject! { |m| m.name == target.name }
end