Class: Role

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/role.rb

Defined Under Namespace

Classes: ProtectedRoleError

Constant Summary collapse

RADIANT_STANDARDS =
['admin', 'designer']

Instance Method Summary collapse

Instance Method Details

#remove_user(user) ⇒ Object



21
22
23
24
25
26
27
28
# File 'app/models/role.rb', line 21

def remove_user(user)
  if users.size <= 1 && allow_empty == false
    return false
  else
    users.delete(user)
    return true
  end
end

#standard?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/role.rb', line 30

def standard?
  RADIANT_STANDARDS.include?(role_name.downcase)
end

#verify_non_standardObject



15
16
17
18
19
# File 'app/models/role.rb', line 15

def verify_non_standard
  if standard?
    raise Role::ProtectedRoleError, "`#{self[:role_name]}' is a protected role and may not be removed."
  end
end