Convert Services to Singleton

This commit is contained in:
Daniel Schädler 2019-05-19 17:43:04 +02:00
parent 56e9c94b6f
commit 4e892fe3a2
4 changed files with 12 additions and 0 deletions

View File

@ -1,6 +1,9 @@
# frozen_string_literal: true
require 'singleton'
class GroupStageService
include Singleton
def self.generate_group_stage(groups)
raise 'Cannot generate group stage without groups' if groups.length.zero?

View File

@ -1,6 +1,9 @@
# frozen_string_literal: true
require 'singleton'
class MatchService
include Singleton
# Generates all necessary matches from a list of teams
#
# @param teams [Array] the teams to generate matches with

View File

@ -1,6 +1,9 @@
# frozen_string_literal: true
require 'singleton'
class PlayoffStageService
include Singleton
# Generates the playoff stage given the tournament
#
# @param teams [Array] The teams to generate the playoff stages with

View File

@ -1,6 +1,9 @@
# frozen_string_literal: true
require 'singleton'
class Utils
include Singleton
# Calculates the previous power of 2 given a number
#
# @param number [Integer] the number to generate the previous power of 2 from