<commit_before>require "rails/render_hooks/version"

module RenderHooks
  extend ActiveSupport::Concern

  included do
    define_callbacks :process_render
    alias_method_chain :render, :render_hooks
  end

  def render_with_render_hooks(*options, &block)
    run_callbacks :process_render do
      render_without_render_hooks(*options, &block)
    end
  end

  module ClassMethods
    [:before, :after, :around].each do |callback|
      define_method "#{callback}_render" do |*names, &block|
        _insert_callbacks(names, block) do |name, options|
          set_callback(:process_render, callback, name, options)
        end
      end
      alias_method :"append_#{callback}_render", :"#{callback}_render"

      define_method "prepend_#{callback}_render" do |*names, &block|
        _insert_callbacks(names, block) do |name, options|
          set_callback(:process_render, callback, name, options.merge(:prepend => true))
        end
      end
<commit_msg>Fix in activesupport 3.2.x<commit_after>require "rails/render_hooks/version"

module RenderHooks
  extend ActiveSupport::Concern

  included do
    define_callbacks :process_render
    alias_method_chain :render, :render_hooks
  end

  def render_with_render_hooks(*options, &block)
    if ActiveSupport::VERSION::STRING >= '4.0.0'
      run_callbacks(:process_render) do
        render_without_render_hooks(*options, &block)
      end
    else
      run_callbacks(:process_render, action_name) do
        render_without_render_hooks(*options, &block)
      end
    end
  end

  module ClassMethods
    [:before, :after, :around].each do |callback|
      define_method "#{callback}_render" do |*names, &block|
        _insert_callbacks(names, block) do |name, options|
          set_callback(:process_render, callback, name, options)
        end
      end
      alias_method :"append_#{callback}_render", :"#{callback}_render"

      define_method "prepend_#{callback}_render" do |*names, &block|
        _insert_callbacks(names, block) do |name, options|
          set_callback(:process_render, callback, name, options.merge(:prepend => true))
        end
      end

{'fraction_non_alphanumeric': 0.1018301267010793, 'fraction_numerical': 0.002346316283435007, 'mean_word_length': 3.727272727272727, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '3068923', 'n_tokens_mistral': 647, 'n_tokens_neox': 649, 'n_words': 147}