Module: Sunrise::Models::User

Extended by:
ActiveSupport::Concern
Included in:
User
Defined in:
lib/sunrise/models/user.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#admin?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/sunrise/models/user.rb', line 55

def admin?
  has_role?(:admin)
end

#default?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/sunrise/models/user.rb', line 47

def default?
  has_role?(:default)
end

#has_role?(role_name) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/sunrise/models/user.rb', line 59

def has_role?(role_name)
  role_symbols.include?(role_name.to_sym)
end

#moderator?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/sunrise/models/user.rb', line 51

def moderator?
  has_role?(:moderator)
end

#role_empty?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/sunrise/models/user.rb', line 63

def role_empty?
  self.role_type_id.nil?
end

#role_symbolObject



71
72
73
# File 'lib/sunrise/models/user.rb', line 71

def role_symbol
  role_symbols.first
end

#role_symbolsObject



67
68
69
# File 'lib/sunrise/models/user.rb', line 67

def role_symbols
  [role_type.try(:code)]
end

#stateObject



75
76
77
78
79
80
# File 'lib/sunrise/models/user.rb', line 75

def state
  return 'active'   if active_for_authentication?
  return 'confirm'  unless confirmed?
  return 'suspend'  if access_locked?
  return 'pending'
end