Class: Renalware::User
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Renalware::User
- Includes:
- Deviseable, Personable
- Defined in:
- app/models/renalware/user.rb
Instance Attribute Summary collapse
-
#with_extended_validation ⇒ Object
Non-persistent attribute to signify we want to use extended validation.
Class Method Summary collapse
- .policy_class ⇒ Object
-
.ransackable_scopes(_auth_object = nil) ⇒ Object
So we can uses these scopes as Ransack predicates eg.
Instance Method Summary collapse
- #generate_new_authentication_token! ⇒ Object
-
#has_role?(name) ⇒ Boolean
rubocop:disable Naming/PredicateName.
-
#professional_signature ⇒ Object
Official name for use when displaying e.g.
-
#role_names ⇒ Object
rubocop:enable Naming/PredicateName.
Instance Attribute Details
#with_extended_validation ⇒ Object
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.
43 44 45 |
# File 'app/models/renalware/user.rb', line 43 def with_extended_validation @with_extended_validation end |
Class Method Details
.policy_class ⇒ Object
45 46 47 |
# File 'app/models/renalware/user.rb', line 45 def self.policy_class UserPolicy end |
.ransackable_scopes(_auth_object = nil) ⇒ Object
So we can uses these scopes as Ransack predicates eg. { expired: true }
50 51 52 |
# File 'app/models/renalware/user.rb', line 50 def self.ransackable_scopes(_auth_object = nil) %i(unapproved inactive expired) end |
Instance Method Details
#generate_new_authentication_token! ⇒ Object
72 73 74 75 76 |
# File 'app/models/renalware/user.rb', line 72 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
55 56 57 |
# File 'app/models/renalware/user.rb', line 55 def has_role?(name) role_names.include?(name.to_s) end |
#professional_signature ⇒ Object
Official name for use when displaying e.g. on a letter. For example:
Dr Isaac Newton (Consultant Gravitationalist)
66 67 68 69 70 |
# File 'app/models/renalware/user.rb', line 66 def professional_signature signed = signature || full_name signed += " (#{professional_position})" if professional_position? signed end |
#role_names ⇒ Object
rubocop:enable Naming/PredicateName
60 61 62 |
# File 'app/models/renalware/user.rb', line 60 def role_names @role_names ||= roles.pluck(:name) end |