diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-26 22:53:34 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-04-26 22:53:34 -0400 |
commit | add6074325e01b35f012f8fe783d5e4349c10a64 (patch) | |
tree | 86d06b0ef5affb9522d48c1aea58841705d2a59e /app/models | |
parent | ab25aac502a768b6a530ada5c46d6aabe6a56c4c (diff) |
Changes to tournament_stage and tournament controller
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/tournament.rb | 25 | ||||
-rw-r--r-- | app/models/tournament_stage.rb | 23 |
2 files changed, 25 insertions, 23 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 61b4700..09a1abb 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -93,4 +93,29 @@ class Tournament < ActiveRecord::Base def sampling @sampling ||= "Sampling::#{self.sampling_method.camelcase}".constantize end + + # YISSSSSS + def self.make_methods(dir) + if @methods[dir].nil? or Rails.env.development? + @methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| filename.split('/').last.sub(/\.rb$/, '')} + end + return @methods[dir] + end + + def self.scoring_methods + make_methods "scoring" + end + + def self.sampling_methods + make_methods "sampling" + end + + def self.scheduling_methods + make_methods "scheduling" + end + + def self.seeding_methods + make_methods "seeding" + end + end diff --git a/app/models/tournament_stage.rb b/app/models/tournament_stage.rb index 84519b9..9352137 100644 --- a/app/models/tournament_stage.rb +++ b/app/models/tournament_stage.rb @@ -25,29 +25,6 @@ class TournamentStage < ActiveRecord::Base return seeding.seed.pair(matches, players) end - def make_methods(dir) - if @methods[dir].nil? or Rails.env.development? - @methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| filename.sub(/.*\/(.*)\.rb/, /\1/)} - end - return @methods[dir] - end - - def scoring_methods - make_methods "scoring" - end - - def sampling_methods - make_methods "sampling" - end - - def scheduling_methods - make_methods "scheduling" - end - - def seeding_methods - make_methods "seeding" - end - # Accessors to the configured methods def scoring |