gitlab-org--gitlab-foss/app/services/boards/lists/destroy_service.rb
Douglas Barbosa Alexandre 478b3d64f8 Remove Boards::BaseService
2016-10-11 11:39:05 -03:00

29 lines
576 B
Ruby

module Boards
module Lists
class DestroyService < BaseService
def execute(list)
return false unless list.destroyable?
@board = list.board
list.with_lock do
decrement_higher_lists(list)
remove_list(list)
end
end
private
attr_reader :board
def decrement_higher_lists(list)
board.lists.movable.where('position > ?', list.position)
.update_all('position = position - 1')
end
def remove_list(list)
list.destroy
end
end
end
end