<commit_before>class ObjectController < ApplicationController
  before_action :set_object, only: [:show, :edit, :update, :destroy]

  def index
    self.objects = object_class.paginate page: params[:page], per_page: 30
  end

  def show
    @direct  = object.traits.direct.paginate  page: params[:direct],  per_page: 15
    @deduced = object.traits.deduced.paginate page: params[:deduced], per_page: 15
  end

  def new
    self.object = object_class.new
    authorize! :manage, object
  end

  def edit
    authorize! :manage, object
  end

  def create
    self.object = object_class.new space_params
    authorize! :manage, object

    if object.save
      redirect_to object, notice: "#{object_class.name} created"
    else
      render action: 'new'
    end
  end

  def update
    authorize! :manage, object
    if object.update space_params
      redirect_to object, notice: "#{object_class.name} updated"
    else
      render action: 'edit'
    end
  end

  def destroy
    authorize! :manage, object
    object.destroy
    redirect_to spaces_url, notice: "#{object_class.name} destroyed"
  end

  private #-----

  def object_class
    self.class.instance_variable_get :@object_class
  end

  def object_name
    object_class.name
  end

  def objects= objs
    instance_variable_set :"@#{object_class.model_name.plural}", objs
  end

  def object= obj
    instance_variable_set :"@#{object_class.model_name.singular}", obj
  end

  def object
    instance_variable_get :"@#{object_class.model_name.singular}"
  end

  def set_object
    self.object = object_class.find params[:id]
  end

  def object_params
    params.require(object_name.lower.to_sym).permit :name, :description
  end
end<commit_msg>Fix references to Spaces in ObjectsController<commit_after>class ObjectController < ApplicationController
  before_action :set_object, only: [:show, :edit, :update, :destroy]

  def index
    self.objects = object_class.paginate page: params[:page], per_page: 30
  end

  def show
    @direct  = object.traits.direct.paginate  page: params[:direct],  per_page: 15
    @deduced = object.traits.deduced.paginate page: params[:deduced], per_page: 15
  end

  def new
    self.object = object_class.new
    authorize! :manage, object
  end

  def edit
    authorize! :manage, object
  end

  def create
    self.object = object_class.new object_params
    authorize! :manage, object

    if object.save
      redirect_to object, notice: "#{object_name.capitalize} created"
    else
      render action: 'new'
    end
  end

  def update
    authorize! :manage, object
    if object.update object_params
      redirect_to object, notice: "#{object_name.capitalize} updated"
    else
      render action: 'edit'
    end
  end

  def destroy
    authorize! :manage, object
    object.destroy
    redirect_to send("#{object_class.model_name.plural}_url"), 
      notice: "#{object_name.capitalize} destroyed"
  end

  private #-----

  def object_class
    self.class.instance_variable_get :@object_class
  end

  def object_name
    object_class.model_name.singular
  end

  def objects= objs
    instance_variable_set :"@#{object_class.model_name.plural}", objs
  end

  def object= obj
    instance_variable_set :"@#{object_name}", obj
  end

  def object
    instance_variable_get :"@#{object_name}"
  end

  def set_object
    self.object = object_class.find params[:id]
  end

  def object_params
    params.require(object_name).permit :name, :description
  end
end
{'fraction_non_alphanumeric': 0.0920863309352518, 'fraction_numerical': 0.0034532374100719426, 'mean_word_length': 3.4, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4315226', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1094, 'n_words': 288}