<commit_before>module Lotus
  module Action
    # HTTP redirect API
    #
    # @since 0.1.0
    module Redirect
      # The HTTP header for redirects
      #
      # @since 0.2.0
      # @api private
      LOCATION = 'Location'.freeze

      private

      # Redirect to the given URL
      #
      # @param url [String] the destination URL
      # @param status [Fixnum] the http code
      #
      # @since 0.1.0
      #
      # @example With default status code (302)
      #   require 'lotus/controller'
      #
      #   class Create
      #     include Lotus::Action
      #
      #     def call(params)
      #       # ...
      #       redirect_to 'http://example.com/articles/23'
      #     end
      #   end
      #
      #   action = Create.new
      #   action.call({}) # => [302, {'Location' => '/articles/23'}, '']
      #
      # @example With custom status code
      #   require 'lotus/controller'
      #
      #   class Create
      #     include Lotus::Action
      #
      #     def call(params)
      #       # ...
      #       redirect_to 'http://example.com/articles/23', status: 301
      #     end
      #   end
      #
      #   action = Create.new
      #   action.call({}) # => [301, {'Location' => '/articles/23'}, '']
      def redirect_to(url, status: 302)
        headers.merge!(LOCATION => url)
        self.status = status
      end
    end
  end
end<commit_msg>Assign redirect location reducing object allocs<commit_after>module Lotus
  module Action
    # HTTP redirect API
    #
    # @since 0.1.0
    module Redirect
      # The HTTP header for redirects
      #
      # @since 0.2.0
      # @api private
      LOCATION = 'Location'.freeze

      private

      # Redirect to the given URL
      #
      # @param url [String] the destination URL
      # @param status [Fixnum] the http code
      #
      # @since 0.1.0
      #
      # @example With default status code (302)
      #   require 'lotus/controller'
      #
      #   class Create
      #     include Lotus::Action
      #
      #     def call(params)
      #       # ...
      #       redirect_to 'http://example.com/articles/23'
      #     end
      #   end
      #
      #   action = Create.new
      #   action.call({}) # => [302, {'Location' => '/articles/23'}, '']
      #
      # @example With custom status code
      #   require 'lotus/controller'
      #
      #   class Create
      #     include Lotus::Action
      #
      #     def call(params)
      #       # ...
      #       redirect_to 'http://example.com/articles/23', status: 301
      #     end
      #   end
      #
      #   action = Create.new
      #   action.call({}) # => [301, {'Location' => '/articles/23'}, '']
      def redirect_to(url, status: 302)
        headers[LOCATION] = url
        self.status = status
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.12208067940552017, 'fraction_numerical': 0.02264685067232838, 'mean_word_length': 1.4646904969485615, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5690284', 'n_tokens_mistral': 909, 'n_tokens_neox': 856, 'n_words': 210}