Sha256: fe7d5ea18dd2481cc2b033ce71a50468e8aa85bdfbea5c7b7509e4957d10a8f6

Contents?: true

Size: 918 Bytes

Versions: 20

Compression:

Stored size: 918 Bytes

Contents

# frozen_string_literal: true

require 'active_support/concern'
require_relative 'setup_controller_concern'

module SnFoil
  module Controller
    module Concerns
      module DestroyControllerConcern
        extend ActiveSupport::Concern

        included do
          include SetupControllerConcern
        end

        def destroy(**options)
          options = setup_destroy(**options)
          model = process_destroy(**options)
          render_destroy(model, **options)
        end

        def setup_destroy(**options)
          setup_options(**options)
        end

        def process_destroy(**options)
          current_context(**options).destroy(**options)
        end

        def render_destroy(model, **_options)
          if model.errors.empty?
            render nil
          else
            render model.errors, status: :unprocessable_entity
          end
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
snfoil-rails-0.9.0 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.8.5 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.8.3 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.8.2 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.8.1 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.8.0 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.7.1 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.7.0 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.5.5 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.5.4 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.5.3 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.5.2 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.5.1 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.5.0 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.4.6 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.4.5 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.4.4 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.4.3 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.4.1 lib/sn_foil/controller/concerns/destroy_controller_concern.rb
snfoil-rails-0.3.0 lib/sn_foil/controller/concerns/destroy_controller_concern.rb