diff options
author | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-05 22:54:06 -0500 |
---|---|---|
committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2014-03-05 22:54:06 -0500 |
commit | 48e1937cfac7e1080c60773533f93c0e371f1e39 (patch) | |
tree | ee23ec39f8c00875048a38f5ee546f2e9a320bfb /app | |
parent | 526bff770017a1f6a66e45b5b6e61840711078b8 (diff) |
User model: implement #join_groups and #leave_groups
Diffstat (limited to 'app')
-rw-r--r-- | app/models/user.rb | 26 |
1 files changed, 26 insertions, 0 deletions
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 |