2019-06-17 08:58:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Boards
|
|
|
|
class DestroyService < Boards::BaseService
|
|
|
|
def execute(board)
|
2021-03-22 05:09:15 -04:00
|
|
|
if boards.size == 1
|
2020-09-11 08:08:50 -04:00
|
|
|
return ServiceResponse.error(message: "The board could not be deleted, because the parent doesn't have any other boards.")
|
|
|
|
end
|
2019-06-17 08:58:48 -04:00
|
|
|
|
2020-09-11 08:08:50 -04:00
|
|
|
board.destroy!
|
|
|
|
|
|
|
|
ServiceResponse.success
|
2019-06-17 08:58:48 -04:00
|
|
|
end
|
2021-03-22 05:09:15 -04:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def boards
|
|
|
|
parent.boards
|
|
|
|
end
|
2019-06-17 08:58:48 -04:00
|
|
|
end
|
|
|
|
end
|