<commit_before>module Rafters::Context
  extend ActiveSupport::Concern

  included do
    attr_accessor :rendered_components
    helper_method :rendered_components
    helper_method :components_for_action
    helper_method :render_component
    alias_method_chain :render, :component
  end

  def render_component(name, options = {})
    component = component(name, options)
    component_renderer.render(component)
  end

  def render_with_component(*args, &block)
    if params[:component]
      component, options = params[:component], params[:options]

      respond_to do |format|
        format.html { render_without_component(text: render_component(component, options)) }
      end
    else
      render_without_component(*args, &block)
    end
  end

  def initialized_components
    @initialized_components ||= {}
  end

  def rendered_components_map
    @@rendered_components_map ||= Hash.new({})
  end

  def components_for_action
    rendered_components_map[controller_name][action_name] ||= []
  end

  def components_for_action=(ary)
    rendered_components_map[controller_name][action_name] = ary
  end

  private

  def component_renderer
    @_component_renderer ||= Rafters::Renderer.new(self, view_context)
  end

  def component(name, options = {})
    component_klass = "#{name}_component".classify.constantize
    component = component_klass.new(options.delete(:as), options)<commit_msg>Remove the Context#components_for_action= method, since it isn't used anywhere.<commit_after>module Rafters::Context
  extend ActiveSupport::Concern

  included do
    attr_accessor :rendered_components
    helper_method :rendered_components
    helper_method :components_for_action
    helper_method :render_component
    alias_method_chain :render, :component
  end

  def render_component(name, options = {})
    component = component(name, options)
    component_renderer.render(component)
  end

  def render_with_component(*args, &block)
    if params[:component]
      component, options = params[:component], params[:options]

      respond_to do |format|
        format.html { render_without_component(text: render_component(component, options)) }
      end
    else
      render_without_component(*args, &block)
    end
  end

  def initialized_components
    @initialized_components ||= {}
  end

  def rendered_components_map
    @@rendered_components_map ||= Hash.new({})
  end

  def components_for_action
    rendered_components_map[controller_name][action_name] ||= []
  end

  private

  def component_renderer
    @_component_renderer ||= Rafters::Renderer.new(self, view_context)
  end

  def component(name, options = {})
    component_klass = "#{name}_component".classify.constantize
    component = component_klass.new(options.delete(:as), options)
{'fraction_non_alphanumeric': 0.08960057574667146, 'fraction_numerical': 0.0, 'mean_word_length': 4.526838966202783, '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': '5279701', 'n_tokens_mistral': 805, 'n_tokens_neox': 787, 'n_words': 164}