Sha256: b00d5d6433c34aa0e0eb4cc211a367ca533cb031ebfb4abce228463b32bdd429

Contents?: true

Size: 573 Bytes

Versions: 7

Compression:

Stored size: 573 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
        record = find_record
        authorize! record

        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

7 entries across 7 versions & 1 rubygems

Version Path
pragma-1.0.0 lib/pragma/operation/destroy.rb
pragma-0.2.0 lib/pragma/operation/destroy.rb
pragma-0.1.4 lib/pragma/operation/destroy.rb
pragma-0.1.3 lib/pragma/operation/destroy.rb
pragma-0.1.2 lib/pragma/operation/destroy.rb
pragma-0.1.1 lib/pragma/operation/destroy.rb
pragma-0.1.0 lib/pragma/operation/destroy.rb