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: belongs_to.rb
    path of file: ./repos/nobrainer/lib/no_brainer/document/association
    
    the code of the file until where you have to start completion: class NoBrainer::Document::Association::BelongsTo
  include NoBrainer::Document::Association::Core

  class Metadata
    VALID_OPTIONS = %i[
      primary_key foreign_key 
    
    def cast_attr(key, value, target_class = nil)
      case value
      when target_model(target_class)
        [foreign_key, value.__send__(primary_key)]
      when nil
        if options[:polymorphic]
          [[foreign_type, foreign_key], nil]
        else
          [foreign_key, nil]
        end