Sha256: ae248861c61c5230e167ef625133dc43979d3a61273d55f52d78314412467e5a

Contents?: true

Size: 730 Bytes

Versions: 18

Compression:

Stored size: 730 Bytes

Contents

# frozen_string_literal: true

module Motor
  class ConfigsController < ApiBaseController
    wrap_parameters :data, except: %i[include fields]

    load_and_authorize_resource

    def index
      render json: { data: Motor::ApiQuery::BuildJson.call(@configs, params) }
    end

    def create
      @config =
        Motor::Config.find_or_initialize_by(key: @config.key).tap do |config|
          config.value = @config.value
        end

      @config.save!
      Motor::Configs::WriteToFile.call

      render json: { data: Motor::ApiQuery::BuildJson.call(@config, params) }
    rescue ActiveRecord::RecordNotUnique
      retry
    end

    private

    def config_params
      params.require(:data).permit!
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
motor-admin-0.1.57 app/controllers/motor/configs_controller.rb
motor-admin-0.1.56 app/controllers/motor/configs_controller.rb
motor-admin-0.1.55 app/controllers/motor/configs_controller.rb
motor-admin-0.1.54 app/controllers/motor/configs_controller.rb
motor-admin-0.1.53 app/controllers/motor/configs_controller.rb
motor-admin-0.1.52 app/controllers/motor/configs_controller.rb
motor-admin-0.1.51 app/controllers/motor/configs_controller.rb
motor-admin-0.1.50 app/controllers/motor/configs_controller.rb
motor-admin-0.1.49 app/controllers/motor/configs_controller.rb
motor-admin-0.1.48 app/controllers/motor/configs_controller.rb
motor-admin-0.1.47 app/controllers/motor/configs_controller.rb
motor-admin-0.1.46 app/controllers/motor/configs_controller.rb
motor-admin-0.1.44 app/controllers/motor/configs_controller.rb
motor-admin-0.1.43 app/controllers/motor/configs_controller.rb
motor-admin-0.1.42 app/controllers/motor/configs_controller.rb
motor-admin-0.1.41 app/controllers/motor/configs_controller.rb
motor-admin-0.1.40 app/controllers/motor/configs_controller.rb
motor-admin-0.1.39 app/controllers/motor/configs_controller.rb