Class: Cdx::User

Inherits:
ApplicationRecord show all
Includes:
Resourceable
Defined in:
app/models/cdx/user.rb

Constant Summary collapse

AVAILABLE_ROLES =
Cdx.user_available_roles.freeze

Instance Method Summary collapse

Methods included from AttachmentMacros

#has_many_attached, #has_one_attached

Instance Method Details

#avatar_url(style = :thumb) ⇒ Object



27
28
29
# File 'app/models/cdx/user.rb', line 27

def avatar_url(style = :thumb)
  avatar&.attachment_file_name ? avatar.attachment.url(style) : gravatar_url
end

#content_header_titleObject

Methods



23
24
25
# File 'app/models/cdx/user.rb', line 23

def content_header_title
  email_was
end

#full_nameObject



35
36
37
# File 'app/models/cdx/user.rb', line 35

def full_name
  "#{first_name} #{last_name}".strip
end

#gravatar_urlObject



31
32
33
# File 'app/models/cdx/user.rb', line 31

def gravatar_url
  "https://www.gravatar.com/avatar/#{Digest::MD5.hexdigest(email.downcase)}"
end

#has_role?(role) ⇒ Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/models/cdx/user.rb', line 39

def has_role?(role)
  roles.include? role.to_s
end