Sha256: e267d7e9e31e0504a4c9aadd0b94b2c391f1b6fdbbea953f39554892540bea28

Contents?: true

Size: 597 Bytes

Versions: 9

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true
module Pragma
  module Operation
    # Finds the requested record, authorizes it and decorates it.
    #
    # @author Alessandro Desantis
    class Destroy < Pragma::Operation::Base
      include Pragma::Operation::Defaults

      def call
        context.record = find_record
        authorize! context.record

        context.record.destroy!

        head :no_content
      end

      protected

      # Finds the requested record.
      #
      # @return [Object]
      def find_record
        self.class.model_klass.find(params[:id])
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pragma-1.2.6 lib/pragma/operation/destroy.rb
pragma-1.2.5 lib/pragma/operation/destroy.rb
pragma-1.2.4 lib/pragma/operation/destroy.rb
pragma-1.2.3 lib/pragma/operation/destroy.rb
pragma-1.2.1 lib/pragma/operation/destroy.rb
pragma-1.2.0 lib/pragma/operation/destroy.rb
pragma-1.1.2 lib/pragma/operation/destroy.rb
pragma-1.1.1 lib/pragma/operation/destroy.rb
pragma-1.1.0 lib/pragma/operation/destroy.rb