Add UpdateMatchScore Interactor

This interactor updates the match score and its state accordingly for a running match
This commit is contained in:
Daniel Schädler 2019-04-16 20:19:50 +02:00
parent 813ab04704
commit 1bdf99ebe9
1 changed files with 16 additions and 0 deletions

View File

@ -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