Sha256: deb4f37ae44847a881fb5ab97043d6bf939d008ca8b9ae567d4bab489d650289
Contents?: true
Size: 752 Bytes
Versions: 2
Compression:
Stored size: 752 Bytes
Contents
# frozen_string_literal: true module Pragma module Operation # Finds an existing record, destroys it and responds 204 No Content. # # @author Alessandro Desantis class Destroy < Pragma::Operation::Base step Macro::Classes() step Macro::Model(:find_by) step Macro::Policy() step :destroy! step :respond! def destroy!(_options, model:, **) unless model.destroy options['result.response'] = Response::UnprocessableEntity.new( errors: model.errors ).decorate_with(Decorator::Error) return false end true end def respond!(options) options['result.response'] = Response::NoContent.new end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pragma-2.1.1 | lib/pragma/operation/destroy.rb |
pragma-2.1.0 | lib/pragma/operation/destroy.rb |