<commit_before>module MultiFetchFragments
  extend ActiveSupport::Concern

  included do
    alias_method_chain :render_collection, :multi_fetch_cache
    alias_method_chain :retrieve_template_keys, :multi_fetch_cache
    alias_method_chain :collection_with_template, :multi_fetch_cache
    alias_method_chain :collection_without_template, :multi_fetch_cache
  end

  private

  delegate :instrument_fragment_cache, :cache_store, :fragment_cache_key, to: '@view.controller'

  def cache_safe_variable_counter
    ('cache_safe_' + @variable_counter.to_s).to_sym
  end

  def retrieve_template_keys_with_multi_fetch_cache
    keys = @locals.keys
    keys << @variable         if @object || @collection
    keys << @variable_counter if @collection
    keys << cache_safe_variable_counter if @collection
    keys
  end

  def collection_with_template_with_multi_fetch_cache
    view, locals, template = @view, @locals, @template
    as, counter = @variable, @variable_counter

    if layout = @options[:layout]
      layout = find_template(layout, @template_keys)
    end

    index = -1
    @collection.map do |object|
      locals[as]      = object
      locals[counter] = (index += 1)

      locals[cache_safe_variable_counter] = cache_safe_variable_counter_value(object) || locals[counter]

      content = template.render(view, locals)
      content = layout.render(view, locals) { content } if layout<commit_msg>Fix typo<commit_after>module MultiFetchFragments
  extend ActiveSupport::Concern

  included do
    alias_method_chain :render_collection, :multi_fetch_cache
    alias_method_chain :retrieve_template_keys, :multi_fetch_cache
    alias_method_chain :collection_with_template, :multi_fetch_cache
    alias_method_chain :collection_without_template, :multi_fetch_cache
  end

  private

  delegate :instrument_fragment_cache, :cache_store, :fragment_cache_key, to: '@view.controller'

  def cache_safe_variable_counter
    ('cache_safe_' + @variable_counter.to_s).to_sym
  end

  def retrieve_template_keys_with_multi_fetch_cache
    keys = @locals.keys
    keys << @variable         if defined?(@object) || @collection
    keys << @variable_counter if @collection
    keys << cache_safe_variable_counter if @collection
    keys
  end

  def collection_with_template_with_multi_fetch_cache
    view, locals, template = @view, @locals, @template
    as, counter = @variable, @variable_counter

    if layout = @options[:layout]
      layout = find_template(layout, @template_keys)
    end

    index = -1
    @collection.map do |object|
      locals[as]      = object
      locals[counter] = (index += 1)

      locals[cache_safe_variable_counter] = cache_safe_variable_counter_value(object) || locals[counter]

      content = template.render(view, locals)
      content = layout.render(view, locals) { content } if layout
{'fraction_non_alphanumeric': 0.08083303918108013, 'fraction_numerical': 0.0014119308153900459, 'mean_word_length': 4.408396946564886, 'pattern_counts': {'":': 0, '<': 15, '<?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': '333089', 'n_tokens_mistral': 858, 'n_tokens_neox': 839, 'n_words': 182}