Class: Lcms::Engine::User

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

Instance Method Summary collapse

Instance Method Details

#full_nameObject



19
20
21
22
23
24
# File 'app/models/lcms/engine/user.rb', line 19

def full_name
  [
    survey&.fetch('first_name', nil),
    survey&.fetch('last_name', nil)
  ].reject(&:blank?).join(' ')
end

#generate_passwordObject



26
27
28
29
30
# File 'app/models/lcms/engine/user.rb', line 26

def generate_password
  pwd = Devise.friendly_token.first(20)
  self.password = pwd
  self.password_confirmation = pwd
end

#nameObject



32
33
34
# File 'app/models/lcms/engine/user.rb', line 32

def name
  super.presence || full_name
end

#ready_to_go?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'app/models/lcms/engine/user.rb', line 36

def ready_to_go?
  admin? || survey.present?
end