Sha256: fd12ecca872d2e90e03e0cd5bd799d5e3439e491d75b5de539f94ef4d93f1431

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

module Olympic
  module Tournament

    extend ActiveSupport::Concern

    included do
      has_many :matches,
        class_name: Olympic::Settings[:match_class],
        foreign_key: Olympic::Settings[:match_tournament_key],
        primary_key: Olympic::Settings[:tournament_primary_key]
      belongs_to :root,
        class_name: Olympic::Settings[:match_class],
        foreign_key: Olympic::Settings[:tournament_root_key],
        primary_key: Olympic::Settings[:match_primary_key]
      has_and_belongs_to_many :teams,
        class_name: Olympic::Settings[:team_class],
        join_table: Olympic::Settings[:team_tournament_join],
        foreign_key: Olympic::Settings[:tournament_join_key],
        association_foreign_key: Olympic::Settings[:team_join_key]
    end

    module ClassMethods
      def create_tournament(teams:, bracket:)
        tournament = new
        Olympic::Bracket.for(bracket, tournament, teams).call
        tournament
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
olympic-0.0.2 lib/olympic/tournament.rb