Class: Groups::SshCertificates::DestroyService
- Inherits:
-
Object
- Object
- Groups::SshCertificates::DestroyService
- Defined in:
- app/services/groups/ssh_certificates/destroy_service.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(group, params) ⇒ DestroyService
constructor
A new instance of DestroyService.
Constructor Details
#initialize(group, params) ⇒ DestroyService
Returns a new instance of DestroyService.
6 7 8 9 |
# File 'app/services/groups/ssh_certificates/destroy_service.rb', line 6 def initialize(group, params) @group = group @params = params end |
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/services/groups/ssh_certificates/destroy_service.rb', line 11 def execute ssh_certificate = group.ssh_certificates.find(params[:ssh_certificates_id]) ssh_certificate.destroy! ServiceResponse.success rescue ActiveRecord::RecordNotFound ServiceResponse.error( message: 'SSH Certificate not found', reason: :not_found ) rescue ActiveRecord::RecordNotDestroyed ServiceResponse.error( message: 'SSH Certificate could not be deleted', reason: :method_not_allowed ) end |