Class: Renalware::User

Inherits:
ApplicationRecord show all
Includes:
Deviseable, Personable
Defined in:
app/models/renalware/user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#with_extended_validationObject

Non-persistent attribute to signify we want to use extended validation. We need to refactor this by ising a form object for updating a user.



41
42
43
# File 'app/models/renalware/user.rb', line 41

def with_extended_validation
  @with_extended_validation
end

Class Method Details

.policy_classObject



43
44
45
# File 'app/models/renalware/user.rb', line 43

def self.policy_class
  UserPolicy
end

.ransackable_scopes(_auth_object = nil) ⇒ Object



47
48
49
# File 'app/models/renalware/user.rb', line 47

def self.ransackable_scopes(_auth_object = nil)
  %i(unapproved inactive)
end

Instance Method Details

#generate_new_authentication_token!Object



69
70
71
72
73
# File 'app/models/renalware/user.rb', line 69

def generate_new_authentication_token!
  build_authentication_token.tap do |token|
    update_column(:authentication_token, token)
  end
end

#has_role?(name) ⇒ Boolean

rubocop:disable Naming/PredicateName

Returns:

  • (Boolean)


52
53
54
# File 'app/models/renalware/user.rb', line 52

def has_role?(name)
  role_names.include?(name.to_s)
end

#professional_signatureObject

Official name for use when displaying e.g. on a letter. For example:

Dr Isaac Newton (Consultant Gravitationalist)


63
64
65
66
67
# File 'app/models/renalware/user.rb', line 63

def professional_signature
  signed = signature || full_name
  signed += " (#{professional_position})" if professional_position?
  signed
end

#role_namesObject

rubocop:enable Naming/PredicateName



57
58
59
# File 'app/models/renalware/user.rb', line 57

def role_names
  @role_names ||= roles.pluck(:name)
end