Class: DesignManagement::DeleteDesignsService

Inherits:
DesignService show all
Includes:
OnSuccessCallbacks, RunsDesignActions
Defined in:
app/services/design_management/delete_designs_service.rb

Constant Summary

Constants included from RunsDesignActions

RunsDesignActions::NoActions

Instance Attribute Summary

Attributes inherited from DesignService

#issue

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from OnSuccessCallbacks

#on_success, #success

Methods included from RunsDesignActions

#run_actions

Methods inherited from DesignService

#collection, #project, #repository, #target_branch

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

#initialize(project, user, params = {}) ⇒ DeleteDesignsService

Returns a new instance of DeleteDesignsService.


8
9
10
11
12
# File 'app/services/design_management/delete_designs_service.rb', line 8

def initialize(project, user, params = {})
  super

  @designs = params.fetch(:designs)
end

Instance Method Details

#commit_messageObject


23
24
25
26
27
28
29
30
31
# File 'app/services/design_management/delete_designs_service.rb', line 23

def commit_message
  n = designs.size

  <<~MSG
  Removed #{n} #{'designs'.pluralize(n)}

  #{formatted_file_list}
  MSG
end

#executeObject


14
15
16
17
18
19
20
21
# File 'app/services/design_management/delete_designs_service.rb', line 14

def execute
  return error('Forbidden!') unless can_delete_designs?

  version = delete_designs!
  EventCreateService.new.destroy_designs(designs, current_user)

  success(version: version)
end