Class: Releases::Links::DestroyService

Inherits:
BaseService show all
Defined in:
app/services/releases/links/destroy_service.rb

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #release

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Constructor Details

This class inherits a constructor from Releases::Links::BaseService

Instance Method Details

#execute(link) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'app/services/releases/links/destroy_service.rb', line 6

def execute(link)
  return ServiceResponse.error(reason: REASON_FORBIDDEN, message: _('Access Denied')) unless allowed?
  return ServiceResponse.error(reason: REASON_NOT_FOUND, message: _('Link does not exist')) unless link

  if link.destroy
    ServiceResponse.success(payload: { link: link })
  else
    ServiceResponse.error(reason: REASON_BAD_REQUEST, message: link.errors.full_messages)
  end
end