You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: sti_helpers.rb
    path of file: ./repos/rails_stuff/lib/rails_stuff/resources_controller
    
    the code of the file until where you have to start completion: require 'active_record/errors'

module RailsStuff
  module ResourcesController
    # Helper methods for controllers which works with STI models.
    module StiHelpers
 
    
        def resource_class_by_type
          @resource_class_by_type ||=
            if resource_class.respond_to?(:types_list)
              resource_class.types_list
            else
              resource_class.descendants
            end.index_by(&:name)
        end