diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-04-27 02:46:11 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-04-27 02:46:11 -0400 |
commit | 6c615c4eaa973d83778fc6d34157f823880765f1 (patch) | |
tree | 112cae9c020e34fdbd3620eea13b3c931e24e71c /app/models | |
parent | 353e0b387b8e76d407f9451c236efbb4bd3a19ef (diff) |
Work on the tournament creation page
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/tournament.rb | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 2d4d6b6..900b6d6 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -50,6 +50,11 @@ class Tournament < ActiveRecord::Base @tournament.settings_raw.all.collect { |x| x.name } end + def empty?() keys.empty? end + def count() keys.count end + def length() count end + def size() count end + def method_missing(name, *args) if name.to_s.ends_with?('=') self[name.to_s.sub(/=$/, '').to_sym] = args.first @@ -95,27 +100,30 @@ class Tournament < ActiveRecord::Base end # YISSSSSS - def self.make_methods(dir) - @methods ||= {} - if @methods[dir].nil? or Rails.env.development? - @methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| File.basename(filename, ".rb").humanize } - end - return @methods[dir] - end - def self.scoring_methods + def scoring_methods make_methods "scoring" end - def self.sampling_methods - make_methods "sampling" + def sampling_methods + make_methods("sampling").collect do |name| + "Sampling::#{name.camelcase}".constantize.works_with?(self.game) + end end - def self.scheduling_methods + def scheduling_methods make_methods "scheduling" end - def self.seeding_methods + def seeding_methods make_methods "seeding" end + + def make_methods(dir) + @@methods ||= {} + if @@methods[dir].nil? or Rails.env.development? + @@methods[dir] = Dir.glob("#{Rails.root}/lib/#{dir}/*.rb").map{|filename| File.basename(filename, ".rb") } + end + return @@methods[dir] + end end |