class ActionController::MiddlewareStack

def build_middleware(klass, args, block)

def build_middleware(klass, args, block)
  options = args.extract_options!
  only   = Array(options.delete(:only)).map(&:to_s)
  except = Array(options.delete(:except)).map(&:to_s)
  args << options unless options.empty?
  strategy = NULL
  list     = nil
  if only.any?
    strategy = INCLUDE
    list     = only
  elsif except.any?
    strategy = EXCLUDE
    list     = except
  end
  Middleware.new(klass, args, list, strategy, block)
end