Skip to content

Instantly share code, notes, and snippets.

@hauleth
Created February 19, 2013 15:13
Show Gist options
  • Save hauleth/4986738 to your computer and use it in GitHub Desktop.
Save hauleth/4986738 to your computer and use it in GitHub Desktop.
class Player < Competitor
belongs_to :team
attr_accessible :birth_date, :nationality
def age
now = Time.now.utc.to_date
now.year - birth_date.year - ((now.month > birth_date.month || (now.month == birth_date.month && now.day >= birth_date.day)) ? 0 : 1)
end
def to_builder
player = super
player.(self, :birth_date, :nationality)
player.race 'Zerg'
player
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment