From a685379aa599bac6a96f657088c8df3cbcec3d22 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Mar 2014 22:38:27 -0500 Subject: User model: implement #in_group? --- app/models/user.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/models/user.rb b/app/models/user.rb index db65dc4..d3c262d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -11,6 +11,21 @@ class User < ActiveRecord::Base # as private. before_create :create_remember_token + def in_group?(group) + case group + when :admin + return ((groups & 2) != 0) + when :host + return ((groups & 1) != 0) + when :player + return true + when :specator + return true + else + return false + end + end + ## # VAILD_EMAIL is the regex used to validate a user given email. VALID_EMAIL_REG = /\A\S+@\S+\.\S+\z/i -- cgit v1.2.3-54-g00ecf