<commit_before>module IndexHelper
  def render_index_document(document)
    field = field_from document: document
    span = []
    if !field.is_a?(Array)
      span << content_tag(:span, style: 'display: block;', dir: field.dir) do
        link_to(field, url_for_document(document), document_link_params(document, {}))
      end
    else
      field.each do |value|
        span << content_tag(:span, style: 'display: block;', dir: value.dir) do
          link_to(value, url_for_document(document), document_link_params(document, {}))
        end
      end
    end
    safe_join span
  end

  # Ensures that only a single string is passed from the IndexPresenter
  # @param current_presenter [Class]
  # @param show_link_field [Symbol]
  # @return [String]
  def index_masonry_document_label(document)
    field = field_from document: document
    Array.wrap(field).first
  end

  private

    def field_from(document:)
      index_presenter(document).label(document_show_link_field(document))
    end
end
<commit_msg>Refactor render_index_document<commit_after>module IndexHelper
  def render_index_document(document)
    field = field_from document: document
    spans = Array.wrap(field).map do |value|
      content_tag(:span, style: 'display: block;', dir: value.dir) do
        link_to(value, url_for_document(document), document_link_params(document, {}))
      end
    end
    safe_join spans
  end

  # Ensures that only a single string is passed from the IndexPresenter
  # @param current_presenter [Class]
  # @param show_link_field [Symbol]
  # @return [String]
  def index_masonry_document_label(document)
    field = field_from document: document
    Array.wrap(field).first
  end

  private

    def field_from(document:)
      index_presenter(document).label(document_show_link_field(document))
    end
end

{'fraction_non_alphanumeric': 0.09155701754385964, 'fraction_numerical': 0.0, 'mean_word_length': 3.853723404255319, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4709405', 'n_tokens_mistral': 566, 'n_tokens_neox': 555, 'n_words': 138}