Class: Integral::User

Inherits:
ApplicationRecord show all
Defined in:
app/models/integral/user.rb

Overview

User model used to represent a authenticated user

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available_localesArray

Returns containing available locales.

Returns:

  • (Array)

    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_filenameString

Return the avatar filename

Returns:

  • (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

Parameters:

  • role_sym (Symbol)

    role(s) to check - Can be array of symbols or one symbol

Returns:

  • (Boolean)

    whether or not user has role(s)



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

Returns:

  • (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