Class: Boards::Lists::BaseDestroyService

Inherits:
BaseService show all
Defined in:
app/services/boards/lists/base_destroy_service.rb

Overview

This class is used by issue and epic board lists for destroying a single list

Direct Known Subclasses

DestroyService

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #parent

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

Methods inherited from BaseService

#initialize

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?

Constructor Details

This class inherits a constructor from Boards::BaseService

Instance Method Details

#execute(list) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/boards/lists/base_destroy_service.rb', line 8

def execute(list)
  unless list.destroyable?
    return ServiceResponse.error(message: "Open and closed lists on a board cannot be destroyed.")
  end

  list.with_lock do
    decrement_higher_lists(list)
    list.destroy!
  end

  ServiceResponse.success
rescue StandardError => e
  Gitlab::ErrorTracking.track_and_raise_for_dev_exception(e)
  ServiceResponse.error(message: "List destroy failed.")
end