<commit_before>module Railjet
  module Util
    module FormHelper
      def form(klass)
        klass.new(clean_params).tap(&:validate!)
      end

      private

      def object_params
        raise NotImplementedError
      end

      def clean_params
        object_params
      end

      def respond_with_errors(object_with_errors)
        raise ArgumentError unless object_with_errors.respond_to?(:errors)

        response = object_with_errors.errors.to_hash(true)
        render json: response, status: :unprocessable_entity
      end
    end
  end
end<commit_msg>Allow to set different status while using #respond_with_errors<commit_after>module Railjet
  module Util
    module FormHelper
      def form(klass)
        klass.new(clean_params).tap(&:validate!)
      end

      private

      def object_params
        raise NotImplementedError
      end

      def clean_params
        object_params
      end

      def respond_with_errors(object_with_errors, status: :unprocessable_entity)
        raise ArgumentError unless object_with_errors.respond_to?(:errors)

        response = object_with_errors.errors.to_hash(true)
        render json: response, status: status
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.05202312138728324, 'fraction_numerical': 0.0, 'mean_word_length': 2.6506024096385543, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5301411', 'n_tokens_mistral': 341, 'n_tokens_neox': 332, 'n_words': 82}