Class: Releases::Links::CreateService

Inherits:
BaseService show all
Defined in:
app/services/releases/links/create_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

#executeObject



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

def execute
  return ServiceResponse.error(reason: REASON_FORBIDDEN, message: _('Access Denied')) unless allowed?

  link = release.links.create(allowed_params)

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