summaryrefslogtreecommitdiff
path: root/app/models/tournament.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/tournament.rb')
-rw-r--r--app/models/tournament.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 7460a7d..61b4700 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -6,6 +6,8 @@ class Tournament < ActiveRecord::Base
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"
+ # Settings #################################################################
+
def settings
@settings ||= Settings.new(self)
end
@@ -57,10 +59,14 @@ class Tournament < ActiveRecord::Base
end
end
+ # Misc. ####################################################################
+
def open?
return true
end
+ # Joining/Leaving ##########################################################
+
def joinable_by?(user)
return (open? and user.can?(:join_tournament) and !players.include?(user))
end
@@ -77,4 +83,14 @@ class Tournament < ActiveRecord::Base
players.delete(user)
end
end
+
+ # Configured methods #######################################################
+
+ def scoring
+ @scoring ||= "Scoring::#{self.scoring_method.camelcase}".constantize
+ end
+
+ def sampling
+ @sampling ||= "Sampling::#{self.sampling_method.camelcase}".constantize
+ end
end