From 4fb8b75769b94244ceb62023be966912c0b4a75e Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Thu, 9 May 2019 09:09:54 +0200 Subject: [PATCH] Add evaluate winner method --- app/models/match.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/models/match.rb b/app/models/match.rb index 8007619..8d96f47 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -21,6 +21,12 @@ class Match < ApplicationRecord private + def evaluate_winner + return nil if match_scores.first.points == match_scores.second.points + + match_scores.max_by(&:points).team + end + def stage_xor_group errors.add(:stage_xor_group, 'Stage and Group missing or both present') unless stage.present? ^ group.present? end