Class: WorkItems::RelatedWorkItemLinks::DestroyService
- Inherits:
-
BaseService
- Object
- BaseService
- WorkItems::RelatedWorkItemLinks::DestroyService
- Defined in:
- app/services/work_items/related_work_item_links/destroy_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(work_item, user, params) ⇒ DestroyService
constructor
A new instance of DestroyService.
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
Constructor Details
#initialize(work_item, user, params) ⇒ DestroyService
Returns a new instance of DestroyService.
6 7 8 9 10 11 12 |
# File 'app/services/work_items/related_work_item_links/destroy_service.rb', line 6 def initialize(work_item, user, params) @work_item = work_item @current_user = user @params = params.dup @failed_ids = [] @removed_ids = [] end |
Instance Method Details
#execute ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/services/work_items/related_work_item_links/destroy_service.rb', line 14 def execute return error(_('No work item found.'), 403) unless can?(current_user, :admin_work_item_link, work_item) return error(_('No work item IDs provided.'), 409) if params[:item_ids].empty? destroy_links_for(params[:item_ids]) if removed_ids.any? success(message: , items_removed: removed_ids, items_with_errors: failed_ids.flatten) else error() end end |