Class: WorkItems::DeleteService

Inherits:
Issuable::DestroyService show all
Defined in:
app/services/work_items/delete_service.rb

Instance Attribute Summary

Attributes inherited from BaseProjectService

#project

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods inherited from BaseProjectService

#initialize

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods inherited from BaseContainerService

#group_container?, #initialize, #namespace_container?, #project_container?

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Instance Method Details

#execute(work_item) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'app/services/work_items/delete_service.rb', line 5

def execute(work_item)
  unless current_user.can?(:delete_work_item, work_item)
    return ::ServiceResponse.error(message: 'User not authorized to delete work item')
  end

  if super
    ::ServiceResponse.success
  else
    ::ServiceResponse.error(message: work_item.errors.full_messages)
  end
end