summaryrefslogtreecommitdiff
path: root/app/services/boards/destroy_service.rb
blob: 0b1cd61b119713c98165a0c267425379378a9399 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# frozen_string_literal: true

module Boards
  class DestroyService < Boards::BaseService
    def execute(board)
      if boards.size == 1
        return ServiceResponse.error(message: "The board could not be deleted, because the parent doesn't have any other boards.")
      end

      board.destroy!

      ServiceResponse.success
    end

    private

    def boards
      parent.boards
    end
  end
end