From 1bdf99ebe9e812d7ae9d7f6445d500daf0978731 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Tue, 16 Apr 2019 20:19:50 +0200 Subject: [PATCH] Add UpdateMatchScore Interactor This interactor updates the match score and its state accordingly for a running match --- app/interactors/update_match_score.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 app/interactors/update_match_score.rb diff --git a/app/interactors/update_match_score.rb b/app/interactors/update_match_score.rb new file mode 100644 index 0000000..e2ebf11 --- /dev/null +++ b/app/interactors/update_match_score.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +class UpdateMatchScore + include Interactor + + def call + match_score = context.match_score + match_score_params = context.match_score_params + if match_score.update(match_score_params) + match_score.match.state = 'in_progress' + context.fail! unless match_score.save + else + context.fail! + end + end +end