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: clever_load.rb
    path of file: ./repos/activerecord-turntable/lib/active_record/turntable/active_record_ext
    
    the code of the file until where you have to start completion: module ActiveRecord::Turntable
  module A
    
      def clever_load!(association_name)
        # load records
        records = self.to_a
        klass = records.first.class
        association_key = association_name.to_s
        reflection = klass.reflections[association_key]

        if reflection
          foreign_class = reflection.klass
          foreign_objects = case reflection.macro
                            when :has_one
                              foreign_class.where(reflection.foreign_key => records.map(&reflection.association_primary_key.to_sym).uniq)
                            when :belongs_to
                              foreign_class.where(reflection.association_primary_key => records.map(&reflection.foreign_key.to_sym).uniq)
                            else
                              []
                            end