Class: Munificent::Admin::User

Inherits:
Munificent::ApplicationRecord
  • Object
show all
Includes:
Authenticable
Defined in:
app/models/munificent/admin/user.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#password_confirmationObject

Returns the value of attribute password_confirmation.



6
7
8
# File 'app/models/munificent/admin/user.rb', line 6

def password_confirmation
  @password_confirmation
end

#require_password=(value) ⇒ Object (writeonly)

Sets the attribute require_password

Parameters:

  • value

    the value to set the attribute require_password to.



7
8
9
# File 'app/models/munificent/admin/user.rb', line 7

def require_password=(value)
  @require_password = value
end

Instance Method Details

#active?Boolean

We may use these later, but for now default them to ‘true`.

Returns:

  • (Boolean)


45
# File 'app/models/munificent/admin/user.rb', line 45

def active? = true

#approved?Boolean

Returns:

  • (Boolean)


46
# File 'app/models/munificent/admin/user.rb', line 46

def approved? = true

#confirmed?Boolean

Returns:

  • (Boolean)


47
# File 'app/models/munificent/admin/user.rb', line 47

def confirmed? = true

#has_2sv?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/munificent/admin/user.rb', line 20

def has_2sv?
  otp_secret.present?
end

#permissionsObject



24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/munificent/admin/user.rb', line 24

def permissions
  if full_access?
    ["full access"]
  else
    [].tap do |perms|
      perms << "data entry" if data_entry?
      perms << "manages users" if manages_users?
      perms << "support" if support?
    end
  end
end

#require_password?Boolean

Returns:

  • (Boolean)


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

def require_password?
  !!@require_password
end

#statesObject



36
37
38
39
40
41
42
# File 'app/models/munificent/admin/user.rb', line 36

def states
  [].tap do |states|
    states << "active" if active?
    states << "approved" if approved?
    states << "confirmed" if confirmed?
  end
end

#to_sObject



49
50
51
# File 'app/models/munificent/admin/user.rb', line 49

def to_s
  name.presence || email_address
end