Class: RequestRefinery::User
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- RequestRefinery::User
- Defined in:
- app/models/request_refinery/user.rb
Instance Method Summary collapse
- #initialize_username ⇒ Object
- #permission_strings ⇒ Object
- #permission_syms ⇒ Object
- #permissions ⇒ Object
Instance Method Details
#initialize_username ⇒ Object
21 22 23 |
# File 'app/models/request_refinery/user.rb', line 21 def initialize_username self.username = self.email if self.username.blank? or User.where(username:self.username).count > 0 end |
#permission_strings ⇒ Object
46 47 48 |
# File 'app/models/request_refinery/user.rb', line 46 def self..collect{|x| x.name} end |
#permission_syms ⇒ Object
42 43 44 |
# File 'app/models/request_refinery/user.rb', line 42 def self..collect{|x| x.name.to_sym} end |
#permissions ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/request_refinery/user.rb', line 25 def # get permissions from Permissions and Roles, account for the :all permission p = super self.roles.each{|x| p += x.} # parse permissions from the user's roles p_a = p.to_a (p_a = Permission.all.to_a) if p.any? {|x| x.name == "all"} # if they have the all permissions, give them all permissions # get restrictions r = self.restrictions r_a = r.to_a # remove restrictions from the permissions p_s = Set.new(p_a) - Set.new(r_a) return p_s.to_a end |