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: associates_self_with_genres.rb
    path of file: ./repos/muvee/app/models/concerns
    
    the code of the file until where you have to start completion: module AssociatesSelfWithGenres

  def associate_self_with_genres(genre_names)
    return unless genre_names.size > 0

    genres = genre_names
      .compact
      .map(&:strip)
      .map(&:titleize)
      .uniq
      .reject(&:blank?)
      .map
    
  def associate_self_with_genres(genre_names)
    return unless genre_names.size > 0

    genres = genre_names
      .compact
      .map(&:strip)
      .map(&:titleize)
      .uniq
      .reject(&:blank?)
      .map{|g| Genre.normalized_name(g) }

    self.genres = []

    genres.each do |genre_name|
      existing_genre = Genre.where(name: genre_name).first
      new_genre = Genre.new(name: genre_name) unless existing_genre.present?
      genre = existing_genre || new_genre

      self.genres << genre if genre.present?
    end

    self.save
  end