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 # frozen_string_literal: true
require 'singleton'
class GroupStageService class GroupStageService
include Singleton
def self.generate_group_stage(groups) def self.generate_group_stage(groups)
raise 'Cannot generate group stage without groups' if groups.length.zero? raise 'Cannot generate group stage without groups' if groups.length.zero?

View File

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

View File

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

View File

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