Add evaluate winner method

This commit is contained in:
Daniel Schädler 2019-05-09 09:09:54 +02:00
parent ae41d1a2a5
commit 4de6847edc
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,12 @@ class Match < ApplicationRecord
private 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 def stage_xor_group
errors.add(:stage_xor_group, 'Stage and Group missing or both present') unless stage.present? ^ group.present? errors.add(:stage_xor_group, 'Stage and Group missing or both present') unless stage.present? ^ group.present?
end end