From 48e1937cfac7e1080c60773533f93c0e371f1e39 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 5 Mar 2014 22:54:06 -0500 Subject: User model: implement #join_groups and #leave_groups --- app/models/user.rb | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'app') diff --git a/app/models/user.rb b/app/models/user.rb index d3c262d..079b870 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -26,6 +26,32 @@ class User < ActiveRecord::Base end end + def join_groups(join=[]) + # FIXME: race condition + join.each do |group| + case group + when :admin + groups |= 2 + when :host + groups |= 1 + else + end + end + end + + def leave_groups(leave=[]) + # FIXME: race condition + leave.each do |group| + case group + when :admin + groups &= ~ 2 + when :host + groups &= ~ 1 + else + end + 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