Replace guard clauses with ternary operator

@thor77 apparently thinks this is better then it was before.. i don't
really care so here we go ¯\_(ツ)_/¯
This commit is contained in:
Daniel Schädler 2019-06-05 00:11:10 +02:00
parent a8744c6987
commit 3f73f7d656
1 changed files with 3 additions and 9 deletions

View File

@ -26,9 +26,7 @@ class Match < ApplicationRecord
end
def winner
return nil unless finished?
current_leading_team
finished? ? current_leading_team : nil
end
def group_match?
@ -36,15 +34,11 @@ class Match < ApplicationRecord
end
def scored_points_of(team)
return 0 unless teams.include?(team)
match_scores.find_by(team: team).points
teams.include?(team) ? match_scores.find_by(team: team).points : 0
end
def received_points_of(team)
return 0 unless teams.include?(team)
match_scores.find { |ms| ms.team != team }.points
teams.include?(team) ? match_scores.find { |ms| ms.team != team }.points : 0
end
def group_points_of(team)