# File lib/action_dispatch/routing/redirection.rb, line 98
      def redirect(*args, &block)
        options = args.last.is_a?(Hash) ? args.pop : {}
        status  = options.delete(:status) || 301

        return OptionRedirect.new(status, options) if options.any?

        path = args.shift

        block = lambda { |params, request|
          (params.empty? || !path.match(/%\{\w*\}/)) ? path : (path % escape(params))
        } if String === path

        block = path if path.respond_to? :call

        # :FIXME: remove in Rails 4.0
        if block && block.respond_to?(:arity) && block.arity < 2
          msg = "redirect blocks with arity of #{block.arity} are deprecated. Your block must take 2 parameters: the environment, and a request object"
          ActiveSupport::Deprecation.warn msg
          deprecated_block = block
          block = lambda { |params, _| deprecated_block.call(params) }
        end

        raise ArgumentError, "redirection argument not supported" unless block

        Redirect.new status, block
      end