diff options
author | Luke Shumaker <shumakl@purdue.edu> | 2014-04-21 10:07:26 -0400 |
---|---|---|
committer | Luke Shumaker <shumakl@purdue.edu> | 2014-04-21 10:07:26 -0400 |
commit | 615c415a05fa219e9d8a43fa0d8863c2deadc04e (patch) | |
tree | a73a0da45f4f89d64bfa798459f989b89bd198d8 /app/models | |
parent | ab3eaa120d11f04721fbe7d670e024358d3c46b0 (diff) | |
parent | 493c2528076076beae43b2574493ed3955c38f4b (diff) |
Merge branch 'clean2'
Conflicts:
start.sh
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/api_requests.rb | 2 | ||||
-rw-r--r-- | app/models/tournament.rb | 28 | ||||
-rw-r--r-- | app/models/tournament_preference.rb | 3 | ||||
-rw-r--r-- | app/models/tournament_setting.rb | 3 |
4 files changed, 19 insertions, 17 deletions
diff --git a/app/models/api_requests.rb b/app/models/api_requests.rb new file mode 100644 index 0000000..19c76e2 --- /dev/null +++ b/app/models/api_requests.rb @@ -0,0 +1,2 @@ +class ApiRequests < ActiveRecord::Base +end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index d3ef12a..bf44cdf 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,7 +1,7 @@ class Tournament < ActiveRecord::Base belongs_to :game has_many :matches - has_many :preferences_raw, class_name: "TournamentPreference" + has_many :settings_raw, class_name: "TournamentSetting" has_and_belongs_to_many :players, class_name: "User", association_foreign_key: "player_id", join_table: "players_tournaments" has_and_belongs_to_many :hosts, class_name: "User", association_foreign_key: "host_id", join_table: "hosts_tournaments" @@ -15,17 +15,17 @@ class Tournament < ActiveRecord::Base return h end - def preferences - @preferences ||= Preferences.new(self) + def settings + @settings ||= Settings.new(self) end - def preferences=(pref) - pref.each do |key, value| - value = false if valuedd == "0" - preferences[key] = value + def settings=(setting) + setting.each do |key, value| + value = false if value == "0" + settings[key] = value end end - class Preferences + class Settings @vartypes = { :true_false => 0, :integer => 1, @@ -38,8 +38,8 @@ class Tournament < ActiveRecord::Base @tournament = tournament end - def [](preference) - p = @tournament.preferences_raw.find_by_name(preference) + def [](setting) + p = @tournament.settings_raw.find_by_name(setting) if p.nil? return nil else @@ -47,10 +47,10 @@ class Tournament < ActiveRecord::Base end end - def []=(preference, val) - p = @tournament.preferences_raw.find_by_name(preference) + def []=(setting, val) + p = @tournament.settings_raw.find_by_name(setting) if p.nil? - TournamentPreference.create( tournament_id: @tournament.id, vartype: get_type(val), name: preference, value: val ) + TournamentSetting.create( tournament_id: @tournament.id, vartype: get_type(val), name: setting, value: val ) else p.value = val end @@ -72,7 +72,7 @@ class Tournament < ActiveRecord::Base end def keys - @tournament.preferences_raw.all.collect { |x| x.name } + @tournament.settings_raw.all.collect { |x| x.name } end def method_missing(name, *args) diff --git a/app/models/tournament_preference.rb b/app/models/tournament_preference.rb deleted file mode 100644 index 3d15061..0000000 --- a/app/models/tournament_preference.rb +++ /dev/null @@ -1,3 +0,0 @@ -class TournamentPreference < ActiveRecord::Base - belongs_to :tournament -end diff --git a/app/models/tournament_setting.rb b/app/models/tournament_setting.rb new file mode 100644 index 0000000..b3e6ace --- /dev/null +++ b/app/models/tournament_setting.rb @@ -0,0 +1,3 @@ +class TournamentSetting < ActiveRecord::Base + belongs_to :tournament +end |