Class: DesignManagement::MoveDesignsService

Inherits:
DesignService show all
Defined in:
app/services/design_management/move_designs_service.rb

Instance Attribute Summary

Attributes inherited from DesignService

#issue

Attributes inherited from BaseService

#current_user, #params, #project

Instance Method Summary collapse

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(user, params) ⇒ MoveDesignsService

Returns a new instance of MoveDesignsService.

Parameters:

  • user (User)

    The current user

  • params (Hash)

Options Hash (params):


10
11
12
# File 'app/services/design_management/move_designs_service.rb', line 10

def initialize(user, params)
  super(nil, user, params.merge(issue: nil))
end

Instance Method Details

#error(message) ⇒ Object


27
28
29
# File 'app/services/design_management/move_designs_service.rb', line 27

def error(message)
  ServiceResponse.error(message: message)
end

#executeObject


14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/services/design_management/move_designs_service.rb', line 14

def execute
  return error(:no_focus) unless current_design.present?
  return error(:cannot_move) unless current_user.can?(:move_design, current_design)
  return error(:no_neighbors) unless neighbors.present?
  return error(:not_distinct) unless all_distinct?
  return error(:not_same_issue) unless all_same_issue?

  move_nulls_to_end
  current_design.move_between(previous_design, next_design)
  current_design.save!
  success
end

#successObject


31
32
33
# File 'app/services/design_management/move_designs_service.rb', line 31

def success
  ServiceResponse.success
end