From 161e46978df890af5eabad43df3de5899ff95722 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Wed, 24 Apr 2019 12:09:56 +0200 Subject: [PATCH] Add Interactor to add group stage to a tournament --- .../add_group_stage_to_tournament.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 app/interactors/add_group_stage_to_tournament.rb diff --git a/app/interactors/add_group_stage_to_tournament.rb b/app/interactors/add_group_stage_to_tournament.rb new file mode 100644 index 0000000..d8071f2 --- /dev/null +++ b/app/interactors/add_group_stage_to_tournament.rb @@ -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