Sha256: 71829952101e4b819adf832270a1f31212c9dac5e76600ab2672bd4e2f5b70a1
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me, :roles # attr_accessible :title, :body ROLES = %w(admin role-1 role-2 role-3) def self.create_oam_user(attributes) user = User.new user.email = attributes[:email] user.roles = attributes[:roles] if attributes[:roles] user.save validate:false end def roles=(roles) self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum end def roles ROLES.reject do |r| ((roles_mask || 0) & 2**ROLES.index(r)).zero? end end def update_roles(roles) self.roles = roles self.save validate:false end def update_user(roles, additional_attributes) self.roles = roles self.email = additional_attributes['user_email'] self.save validate:false end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
devise_oam-0.0.4 | test/dummy/app/models/user.rb |
devise_oam-0.0.3 | test/dummy/app/models/user.rb |