<commit_before>class MapOverlaysSerializer

  def initialize(overlays, yml)
    @overlays = overlays
    @yml = yml
  end

  def serialize
    @overlays.map do |overlay|
      overlay.merge({
        title: @yml[:overlays][overlay[:id].to_sym][:title],
        layers: get_layers(overlay)      
      })
    end
  end

  private

  def get_layers(overlay)
    max_index = overlay[:layers].count-1

    (0..max_index).map{ |i| get_layer(overlay, i) }
  end

  def get_layer(overlay, index)
    layer = overlay[:layers][index]<commit_msg>catch nil case for overlay yml<commit_after>class MapOverlaysSerializer

  def initialize(overlays, yml)
    @overlays = overlays
    @yml = yml
  end

  def serialize
    @overlays.map do |overlay|
      overlay_yml = @yml[:overlays][overlay[:id].to_sym]

      overlay.merge({
        title: overlay_yml.nil? ? '' : overlay_yml[:title],
        layers: get_layers(overlay)      
      })
    end
  end

  private

  def get_layers(overlay)
    max_index = overlay[:layers].count-1

    (0..max_index).map{ |i| get_layer(overlay, i) }
  end

  def get_layer(overlay, index)
    layer = overlay[:layers][index]
{'fraction_non_alphanumeric': 0.1212914485165794, 'fraction_numerical': 0.0034904013961605585, 'mean_word_length': 2.9688581314878895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2222966', 'n_tokens_mistral': 418, 'n_tokens_neox': 387, 'n_words': 81}