Class: Boards::Lists::BaseCreateService

Inherits:
BaseService show all
Includes:
Gitlab::Utils::StrongMemoize
Defined in:
app/services/boards/lists/base_create_service.rb

Overview

This class is used by issue and epic board lists for creating new list

Direct Known Subclasses

CreateService

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #parent

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

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(board) ⇒ Object


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/services/boards/lists/base_create_service.rb', line 10

def execute(board)
  list = case type
         when :backlog
           create_backlog(board)
         else
           target = target(board)
           position = next_position(board)

           return ServiceResponse.error(message: _('%{board_target} not found') % { board_target: type.to_s.capitalize }) if target.blank?

           create_list(board, type, target, position)
         end

  return ServiceResponse.error(message: list.errors.full_messages) unless list.persisted?

  ServiceResponse.success(payload: { list: list })
end