Sha256: 0f45786108d6f6eb6ee9e6f0dc87779c3347c09dc39ac49ec65361dfe101d37d

Contents?: true

Size: 693 Bytes

Versions: 3

Compression:

Stored size: 693 Bytes

Contents

# frozen_string_literal: true

module SportsManager
  class TeamBuilder
    attr_reader :category, :subscriptions, :participants

    def initialize(category:, subscriptions:)
      @category = category
      @subscriptions = subscriptions
      @participants = subscriptions.flatten
    end

    def build
      subscriptions.map(&method(:build_team))
    end

    private

    def build_team(team)
      team_participants = Utils::Array
        .wrap(team)
        .map { |participant| build_participant(participant) }

      Team.for(category: category, participants: team_participants)
    end

    def build_participant(participant)
      Participant.new(**participant)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sports-manager-0.0.3 lib/sports_manager/team_builder.rb
sports-manager-0.0.2 lib/sports_manager/team_builder.rb
sports-manager-0.0.1 lib/sports_manager/team_builder.rb