Add Interactor to add group stage to a tournament

This commit is contained in:
Daniel Schädler 2019-04-24 12:09:56 +02:00
parent 4059c0d09c
commit 161e46978d
1 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
class AddGroupStageToTournament
include Interactor
def call
tournament = context.tournament
groups = context.groups
context.fail! if tournament.stages.size > 1
if (group_stage = GroupStageService.generate_group_stage(groups))
tournament.stages = [group_stage]
context.tournament = tournament
else
context.fail!
end
end
end