Sha256: 3e3653b23800f01dd8976bb6434e2022f3184f5cb5aaf66204bb750a788d5e4c

Contents?: true

Size: 904 Bytes

Versions: 8

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

module Maglev
  module API
    class AssetsController < ::Maglev::APIController
      include ::ActiveStorage::SetCurrent

      def index
        @assets = resources.search(
          params[:query], params[:asset_type], params[:page], params[:per_page]
        )
      end

      def show
        @asset = resources.find(params[:id])
      end

      def create
        asset = resources.create!(asset_params)
        head :created, location: api_asset_path(asset), maglev_asset_id: asset.id
      end

      def update
        resources.find(params[:id]).update!(asset_params)
        head :ok
      end

      def destroy
        resources.find(params[:id]).destroy!
        head :no_content
      end

      private

      def asset_params
        params.require(:asset).permit(:file)
      end

      def resources
        ::Maglev::Asset
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
maglevcms-1.1.3 app/controllers/maglev/api/assets_controller.rb
maglevcms-1.1.2 app/controllers/maglev/api/assets_controller.rb
maglevcms-1.1.1 app/controllers/maglev/api/assets_controller.rb
maglevcms-1.1.0 app/controllers/maglev/api/assets_controller.rb
maglevcms-1.0.0 app/controllers/maglev/api/assets_controller.rb
maglevcms-1.0.0.rc3 app/controllers/maglev/api/assets_controller.rb
maglevcms-1.0.0.rc2 app/controllers/maglev/api/assets_controller.rb
maglevcms-1.0.0.rc1 app/controllers/maglev/api/assets_controller.rb