2019-09-30 21:07:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Boards
|
|
|
|
class DestroyService < Boards::BaseService
|
|
|
|
def execute(board)
|
2021-04-29 21:17:54 +05:30
|
|
|
if boards.size == 1
|
2020-11-24 15:15:51 +05:30
|
|
|
return ServiceResponse.error(message: "The board could not be deleted, because the parent doesn't have any other boards.")
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
board.destroy!
|
|
|
|
|
|
|
|
ServiceResponse.success
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
2021-04-29 21:17:54 +05:30
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def boards
|
|
|
|
parent.boards
|
|
|
|
end
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|