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: eager.rb
    path of file: ./repos/mongoid/lib/mongoid/association/referenced/has_one
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
# rubocop:todo all

mo
    
          def preload
            @docs.each do |d|
              set_relation(d, nil)
            end

            each_loaded_document do |doc|
              id = doc.send(key)
              set_on_parent(id, doc)
            end
          end

          def group_by_key
            @association.primary_key
          end

          def key
            @association.foreign_key
          end

        end
      end