<commit_before>class JbuilderTemplate < Jbuilder
  def initialize(context, *args)
    @context = context
    super(*args)
  end

  def partial!(options, locals = {})
    case options
    when ::Hash
      options[:locals] ||= {}
      options[:locals].merge!(:json => self)
      @context.render(options)
    else
      @context.render(options, locals.merge(:json => self))
    end
  end

  # Caches the json constructed within the block passed. Has the same signature as the `cache` helper
  # method in `ActionView::Helpers::CacheHelper` and so can be used in the same way.
  #
  # Example:
  #
  #   json.cache! ['v1', @person], :expires_in => 10.minutes do
  #     json.extract! @person, :name, :age
  #   end
  def cache!(key=nil, options={}, &block)
    options[:force] = true unless @context.controller.perform_caching
    value = ::Rails.cache.fetch(_cache_key(key), options) do
      _scope { yield self }
    end
    _merge(value)
  end

  protected
  def _cache_key(key)
    if @context.respond_to?(:fragment_name_with_digest)
      @context.fragment_name_with_digest(key)
    else
      ::ActiveSupport::Cache.expand_cache_key(key.is_a?(::Hash) ? url_for(key).split("://").last : key, :jbuilder)
    end
  end
end
<commit_msg>Fix some code style issues<commit_after>class JbuilderTemplate < Jbuilder
  def initialize(context, *args)
    @context = context
    super(*args)
  end

  def partial!(options, locals = {})
    case options
    when ::Hash
      options[:locals] ||= {}
      options[:locals].merge!(:json => self)
      @context.render(options)
    else
      @context.render(options, locals.merge(:json => self))
    end
  end

  # Caches the json constructed within the block passed. Has the same signature as the `cache` helper
  # method in `ActionView::Helpers::CacheHelper` and so can be used in the same way.
  #
  # Example:
  #
  #   json.cache! ['v1', @person], :expires_in => 10.minutes do
  #     json.extract! @person, :name, :age
  #   end
  def cache!(key=nil, options={}, &block)
    options[:force] = true unless @context.controller.perform_caching
    value = ::Rails.cache.fetch(_cache_key(key), options) do
      _scope { yield self }
    end

    _merge(value)
  end

  protected
    def _cache_key(key)
      if @context.respond_to?(:fragment_name_with_digest)
        @context.fragment_name_with_digest(key)
      else
        ::ActiveSupport::Cache.expand_cache_key(key.is_a?(::Hash) ? url_for(key).split("://").last : key, :jbuilder)
      end
    end
end

{'fraction_non_alphanumeric': 0.13178913738019168, 'fraction_numerical': 0.0023961661341853034, 'mean_word_length': 3.289383561643836, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 9, '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': '6853497', 'n_tokens_mistral': 818, 'n_tokens_neox': 806, 'n_words': 202}