2019-06-17 08:58:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Boards
|
|
|
|
class DestroyService < Boards::BaseService
|
|
|
|
def execute(board)
|
2020-09-11 08:08:50 -04:00
|
|
|
if parent.boards.size == 1
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end
|