Class: SlashAdmin::Admin

Inherits:
ApplicationRecord show all
Includes:
CanCan::Ability
Defined in:
app/models/slash_admin/admin.rb

Constant Summary collapse

EMAIL_REGEX =
/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i
USERNAME_REGEX =
/^[a-zA-Z0-9_\.]*$/

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loginObject

Returns the value of attribute login.



9
10
11
# File 'app/models/slash_admin/admin.rb', line 9

def 
  @login
end

Instance Method Details

#handle_default_roleObject



31
32
33
# File 'app/models/slash_admin/admin.rb', line 31

def handle_default_role
  self.roles = "superadmin" unless roles.present?
end

#has_role?(role) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
# File 'app/models/slash_admin/admin.rb', line 23

def has_role?(role)
  if roles.blank?
    false
  else
    roles.include?(role)
  end
end

#identiconObject



41
42
43
# File 'app/models/slash_admin/admin.rb', line 41

def identicon
  RubyIdenticon.create_base64(email, grid_size: 5, border_size: 150, square_size: 50, background_color: 0xf0f0f0ff)
end