Module: Sunrise::Models::User
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #admin? ⇒ Boolean
- #default? ⇒ Boolean
- #has_role?(role_name) ⇒ Boolean
- #moderator? ⇒ Boolean
- #role_empty? ⇒ Boolean
- #role_symbol ⇒ Object
- #role_symbols ⇒ Object
- #state ⇒ Object
Instance Method Details
#admin? ⇒ Boolean
55 56 57 |
# File 'lib/sunrise/models/user.rb', line 55 def admin? has_role?(:admin) end |
#default? ⇒ Boolean
47 48 49 |
# File 'lib/sunrise/models/user.rb', line 47 def default? has_role?(:default) end |
#has_role?(role_name) ⇒ 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
51 52 53 |
# File 'lib/sunrise/models/user.rb', line 51 def moderator? has_role?(:moderator) end |
#role_empty? ⇒ Boolean
63 64 65 |
# File 'lib/sunrise/models/user.rb', line 63 def role_empty? self.role_type_id.nil? end |
#role_symbol ⇒ Object
71 72 73 |
# File 'lib/sunrise/models/user.rb', line 71 def role_symbol role_symbols.first end |
#role_symbols ⇒ Object
67 68 69 |
# File 'lib/sunrise/models/user.rb', line 67 def role_symbols [role_type.try(:code)] end |
#state ⇒ Object
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 |