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

  included do
    helper_method :render_component
    alias_method_chain :render, :component
  end

  def component_attributes(name, options = {})
    component = component(name, options)
    component.as_json
  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)) }
        format.json { render_without_component(json: component_attributes(component, options)) }
      end
    else
      render_without_component(*args, &block)
    end
  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)
  end<commit_msg>Remove unused methods from context<commit_after>module Rafters::Context
  extend ActiveSupport::Concern

  included do
    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

  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)
  end
{'fraction_non_alphanumeric': 0.09492168960607499, 'fraction_numerical': 0.0, 'mean_word_length': 4.256857855361596, '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': '3673277', 'n_tokens_mistral': 597, 'n_tokens_neox': 594, 'n_words': 131}