module Concerns::OverallBar::Races::InstanceMethods

Public Instance Methods

create_races() click to toggle source
# File app/models/competitions/concerns/overall_bar/races.rb, line 19
def create_races
  [ 'Senior Men', 'Category 3 Men', 'Category 4/5 Men',
    'Senior Women', 'Category 3 Women', 'Category 4 Women',
    'Junior Men', 'Junior Women', 'Masters Men', 'Masters Women',
    'Masters Men 4/5', 'Masters Women 4',
  'Singlespeed/Fixed', 'Tandem', "Clydesdale" ].each do |category_name|
    races.create :category => ::Category.find_or_create_by_name(category_name)
  end
end
find_race(discipline, category) click to toggle source
# File app/models/competitions/concerns/overall_bar/races.rb, line 7
def find_race(discipline, category)
  if Discipline[:overall] == discipline
    event = self
  else
    event = children.detect { |e| e.discipline == discipline.name }
  end

  if event
    event.races.detect { |e| e.category == category }
  end
end