summaryrefslogtreecommitdiff
path: root/app/models/tournament_setting.rb
blob: 48c607e919a441af3405c7858b3126eb33866a1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class TournamentSetting < ActiveRecord::Base
	belongs_to :tournament

	validates(:vartype, presence: true, numericality: {only_integer: true})
	validates(:type_opt, presence: true, if: :needs_type_opt?)

	def owned_by?(user)
		self.tournament.owned_by?(user)
	end

	def needs_type_opt?
		[
			GameSetting.types[:pick_one_radio],
			GameSetting.types[:pick_one_dropdown],
			GameSetting.types[:pick_several],
		].include? self.vartype
	end


	def self.types
		GameSetting.types
	end
end