<commit_before>module Api
  module V1
    class ApplianceConfigurationTemplatesController < Api::ApplicationController
      load_and_authorize_resource :appliance_configuration_template
      respond_to :json

      def index
        respond_with @appliance_configuration_templates.where(filter)
      end

      def show
        respond_with @appliance_configuration_template
      end

      def create
        @appliance_configuration_template.save!
        render json: @appliance_configuration_template, status: :created
      end

      def update
        @appliance_configuration_template.update_attributes!(update_params)
        render json: @appliance_configuration_template
      end

      def destroy
        if @appliance_configuration_template.destroy
          render json: {}
        else
          render_error @appliance_configuration_template
        end
      end

      private

      def filter
        filter = {}
        ApplianceConfigurationTemplate.new.attributes.keys.each do |attr|
          key = attr.to_sym
          filter[key] = params[key].to_s.split(',') if params[key]
        end
        filter
      end

      def appliance_configuration_template_params
        params.require(:appliance_configuration_template).permit(:name, :payload, :appliance_type_id)
      end

      def update_params
        params.require(:appliance_configuration_template).permit(:name, :payload)
      end
    end
  end
end<commit_msg>tmp variable removed, inject instead of each<commit_after>module Api
  module V1
    class ApplianceConfigurationTemplatesController < Api::ApplicationController
      load_and_authorize_resource :appliance_configuration_template
      respond_to :json

      def index
        respond_with @appliance_configuration_templates.where(filter)
      end

      def show
        respond_with @appliance_configuration_template
      end

      def create
        @appliance_configuration_template.save!
        render json: @appliance_configuration_template, status: :created
      end

      def update
        @appliance_configuration_template.update_attributes!(update_params)
        render json: @appliance_configuration_template
      end

      def destroy
        if @appliance_configuration_template.destroy
          render json: {}
        else
          render_error @appliance_configuration_template
        end
      end

      private

      def filter
        ApplianceConfigurationTemplate.new.attributes.keys.inject({}) do |filter, attr|
          key = attr.to_sym
          filter[key] = params[key].to_s.split(',') if params[key]
          filter
        end
      end

      def appliance_configuration_template_params
        params.require(:appliance_configuration_template).permit(:name, :payload, :appliance_type_id)
      end

      def update_params
        params.require(:appliance_configuration_template).permit(:name, :payload)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.056218057921635436, 'fraction_numerical': 0.0006814310051107325, 'mean_word_length': 2.740127388535032, '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': '6542239', 'n_tokens_mistral': 783, 'n_tokens_neox': 738, 'n_words': 161}