Sha256: d7ac8065b5d10abbae0a3fa69590755b19d6ea9dce4b7f118513a449e8f0ad99
Contents?: true
Size: 841 Bytes
Versions: 1
Compression:
Stored size: 841 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), fail_fast: true step Macro::Policy(), fail_fast: true step :destroy! failure :handle_invalid_model!, fail_fast: true step :respond! def destroy!(_options, model:, **) model.destroy end def handle_invalid_model!(options, model:, **) options['result.response'] = Response::UnprocessableEntity.new( errors: model.errors ).decorate_with(Decorator::Error) end def respond!(options) options['result.response'] = Response::NoContent.new end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pragma-2.0.0 | lib/pragma/operation/destroy.rb |