Last active
December 29, 2015 07:08
-
-
Save rdetert/7633417 to your computer and use it in GitHub Desktop.
Sport Statistics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SportStatistic | |
include Mongoid::Document | |
end | |
class AthleteStatistic < SportStatistic | |
end | |
class SoccerAthleteStatistic < AthleteStatistic | |
field: goals | |
field: assists | |
field: red_cards | |
field: yellow_cards | |
end | |
class GameStatistic < SportStatistic | |
end | |
class SoccerGameStatistic < GameStatistic | |
field: penalty_time | |
field: red_cards | |
field: yellow_cards | |
end | |
class User | |
include Mongoid::Document | |
field :username | |
field :password | |
field :email | |
end | |
class Coach < User | |
end | |
class Athlete < User | |
# will be broken down by sport, one sub document per sport | |
# When a match_statistic is added, these stats will be recalculated to average them all by sport | |
embeds_many AthleteStatistics, as: :career_statistics | |
# broken down by sport, multiple sub documents per sport | |
embeds_many AthleteStatistics, as: :match_statistics | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment