debian-mirror-gitlab/app/services/boards/lists/destroy_service.rb

26 lines
529 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
module Boards
module Lists
class DestroyService < Boards::BaseService
def execute(list)
return false unless list.destroyable?
list.with_lock do
decrement_higher_lists(list)
remove_list(list)
end
end
private
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