From 26267deba0968a0b59b717e4ed725460658aadc0 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Wed, 29 May 2019 15:43:24 +0200 Subject: [PATCH] Implement method to check which is leading --- app/models/match.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/models/match.rb b/app/models/match.rb index 2779fa7..5779038 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -19,13 +19,18 @@ class Match < ApplicationRecord stage ? stage.owner : group.owner end - def winner - return nil unless finished? + def current_leading_team return nil if match_scores.first.points == match_scores.second.points match_scores.max_by(&:points).team end + def winner + return nil unless finished? + + current_leading_team + end + def group_match? group.present? end