Files

24 lines
535 B
Ruby

module Tournaments
class EnsureBroadcastTeam
def self.call(tournament)
new(tournament).call
end
def initialize(tournament)
@tournament = tournament
end
def call
return @tournament.broadcast_team if @tournament.broadcast_team.present?
team = @tournament.club.teams.create!(
name: @tournament.name,
sport_key: @tournament.sport_key,
internal_kind: Tournament::INTERNAL_TEAM_KIND
)
@tournament.update!(broadcast_team: team)
team
end
end
end