<commit_before>module SmartManagement
  module ControllerScaffold
    include SmartManagement::Helpers

    def index
      respond_to do |format|
        format.html { render 'index' }
        format.json do
          render json: SmartManagement::IndexBuilder.
            new(model_class, smart_management_options).call
        end
      end
    end

    def show
      respond_with(resource)
    end

    def create
      resource.save
      respond_with(resource)
    end

    def update
      if resource.save
        render json: resource, status: :ok
      else
        render json: { errors: resource.errors }, status: :unprocessable_entity
      end
    end

    def destroy
      resource.destroy
      respond_with(resource)
    end

    private

    def resource_attributes
      params.require(singular_model_name.to_sym).permit(editable_columns.map(&:to_sym))
    end

    def sort_options
      JSON.parse(params["sort"]).symbolize_keys if params["sort"]
    end

    def pagination_options
      JSON.parse(params["pagination"]).symbolize_keys if params["pagination"]
    end

    def search_options
      if params["search"]
        search_params = JSON.parse(params["search"])
        if search_params["predicateObject"]
          search_params["predicateObject"].symbolize_keys
        end
      end
    end

    def smart_management_options
      { sort: sort_options, pagination: pagination_options, search: search_options }
    end

    private

    def self.included(controller)
      controller.decent_configuration do
        strategy DecentExposure::StrongParametersStrategy
      end

      name = controller.controller_name
      singular = name.singularize
      controller.expose(name, attributes: :resource_attributes)
      controller.expose(singular, attributes: :resource_attributes)
      controller.respond_to :html, :json
    end

    def _prefixes
      super << 'smart_management'
    end

    def resource
      @resource ||= send(singular_model_name)
    end
  end
end
<commit_msg>Correct the convertion to sym<commit_after>module SmartManagement
  module ControllerScaffold
    include SmartManagement::Helpers

    def index
      respond_to do |format|
        format.html { render 'index' }
        format.json do
          render json: SmartManagement::IndexBuilder.
            new(model_class, smart_management_options).call
        end
      end
    end

    def show
      respond_with(resource)
    end

    def create
      resource.save
      respond_with(resource)
    end

    def update
      if resource.save
        render json: resource, status: :ok
      else
        render json: { errors: resource.errors }, status: :unprocessable_entity
      end
    end

    def destroy
      resource.destroy
      respond_with(resource)
    end

    private

    def resource_attributes
      params.require(singular_model_name.to_sym).permit(editable_columns_syms)
    end

    def editable_columns_syms
      editable_columns.map do |column|
        column.name.to_sym
      end
    end

    def sort_options
      JSON.parse(params["sort"]).symbolize_keys if params["sort"]
    end

    def pagination_options
      JSON.parse(params["pagination"]).symbolize_keys if params["pagination"]
    end

    def search_options
      if params["search"]
        search_params = JSON.parse(params["search"])
        if search_params["predicateObject"]
          search_params["predicateObject"].symbolize_keys
        end
      end
    end

    def smart_management_options
      { sort: sort_options, pagination: pagination_options, search: search_options }
    end

    private

    def self.included(controller)
      controller.decent_configuration do
        strategy DecentExposure::StrongParametersStrategy
      end

      name = controller.controller_name
      singular = name.singularize
      controller.expose(name, attributes: :resource_attributes)
      controller.expose(singular, attributes: :resource_attributes)
      controller.respond_to :html, :json
    end

    def _prefixes
      super << 'smart_management'
    end

    def resource
      @resource ||= send(singular_model_name)
    end
  end
end

{'fraction_non_alphanumeric': 0.06813819577735125, 'fraction_numerical': 0.0, 'mean_word_length': 2.618923611111111, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4881691', 'n_tokens_mistral': 1163, 'n_tokens_neox': 1118, 'n_words': 268}