<commit_before>class   HumanError
module  RescuableResource
  module ClassMethods
    def plural_resource_name
      name[/(\w+)Controller\z/, 1].
      underscore.
      pluralize.
      downcase
    end

    def singular_resource_name
      name[/(\w+)Controller\z/, 1].
      underscore.
      singularize.
      downcase
    end
  end

  def self.included(base)
    base.extend ClassMethods

    base.rescue_from 'ActiveRecord::RecordInvalid',
                'ActiveRecord::RecordNotSaved',
                'ActiveRecord::RecordNotFound',
                'ActiveRecord::InvalidForeignKey',
                'ActionController::ParameterMissing' do |exception|
      human_error = HumanError.convert(exception,
                                       resource_name: self.class.singular_resource_name,
                                       action:        action_name)

      render json:   human_error,
             status: human_error.http_status
    end

    base.rescue_from 'HumanError::Error' do |exception|
      render json:   exception,
             status: exception.http_status
    end
  end
end
end<commit_msg>Style: Make whitespace changes<commit_after>class   HumanError
module  RescuableResource
  module ClassMethods
    def plural_resource_name
      name[/(\w+)Controller\z/, 1].
      underscore.
      pluralize.
      downcase
    end

    def singular_resource_name
      name[/(\w+)Controller\z/, 1].
      underscore.
      singularize.
      downcase
    end
  end

  def self.included(base)
    base.extend ClassMethods

    base.rescue_from 'ActiveRecord::RecordInvalid',
                     'ActiveRecord::RecordNotSaved',
                     'ActiveRecord::RecordNotFound',
                     'ActiveRecord::InvalidForeignKey',
                     'ActionController::ParameterMissing' do |exception|
      human_error = HumanError.convert(exception,
                                       resource_name: self.class.singular_resource_name,
                                       action:        action_name)

      render json:   human_error,
             status: human_error.http_status
    end

    base.rescue_from 'HumanError::Error' do |exception|
      render json:   exception,
             status: exception.http_status
    end
  end
end
end
{'fraction_non_alphanumeric': 0.07496711968434897, 'fraction_numerical': 0.0017536168347216134, 'mean_word_length': 1.9107142857142858, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '113876', 'n_tokens_mistral': 618, 'n_tokens_neox': 579, 'n_words': 122}