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: enumerable.rb
    path of file: ./repos/brew/Library/Homebrew/vendor/bundle-standalone/ruby/2.3.0/gems/activesupport-5.2.2/lib/active_support/core_ext
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Enumerable
  # 
    
  def index_by
    if block_given?
      result = {}
      each { |elem| result[yield(elem)] = elem }
      result
    else
      to_enum(:index_by) { size if respond_to?(:size) }
    end