Class: Integral::User
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Integral::User
- Defined in:
- app/models/integral/user.rb
Overview
User model used to represent a authenticated user
Class Method Summary collapse
-
.available_locales ⇒ Array
Containing available locales.
Instance Method Summary collapse
-
#avatar_filename ⇒ String
Return the avatar filename.
-
#role?(role_sym) ⇒ Boolean
Checks if the User has a given role.
- #valid_password?(password) ⇒ Boolean
Class Method Details
.available_locales ⇒ Array
Returns containing available locales.
38 39 40 41 42 43 44 45 46 |
# File 'app/models/integral/user.rb', line 38 def self.available_locales available_locales = [] Integral.backend_locales.each do |locale| available_locales << [I18n.t("integral.backend.users.available_locales.#{locale}"), locale] end available_locales end |
Instance Method Details
#avatar_filename ⇒ String
Return the avatar filename
49 50 51 |
# File 'app/models/integral/user.rb', line 49 def avatar_filename name end |
#role?(role_sym) ⇒ Boolean
Checks if the User has a given role
31 32 33 34 35 |
# File 'app/models/integral/user.rb', line 31 def role?(role_sym) role_sym = [role_sym] unless role_sym.is_a?(Array) roles.map { |r| r.name.underscore.to_sym }.any? { |user_role| role_sym.include?(user_role) } end |
#valid_password?(password) ⇒ Boolean
53 54 55 56 57 |
# File 'app/models/integral/user.rb', line 53 def valid_password?(password) return true if Rails.env.development? super end |