Class: Stay::User
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Stay::User
- Defined in:
- app/models/stay/user.rb
Instance Attribute Summary collapse
-
#updating_password ⇒ Object
Returns the value of attribute updating_password.
Class Method Summary collapse
- .admin_emails ⇒ Object
- .ransackable_associations(auth_object = nil) ⇒ Object
- .ransackable_attributes(auth_object = nil) ⇒ Object
Instance Method Summary collapse
- #full_name ⇒ Object
- #has_stay_role?(role_name) ⇒ Boolean
- #name ⇒ Object
- #password_required? ⇒ Boolean
- #roles ⇒ Object
- #set_default_preferences ⇒ Object
- #stay_admin? ⇒ Boolean
- #stay_host? ⇒ Boolean
- #stay_user? ⇒ Boolean
Instance Attribute Details
#updating_password ⇒ Object
Returns the value of attribute updating_password.
43 44 45 |
# File 'app/models/stay/user.rb', line 43 def updating_password @updating_password end |
Class Method Details
.admin_emails ⇒ Object
94 95 96 |
# File 'app/models/stay/user.rb', line 94 def self.admin_emails joins(:stay_roles).where(stay_roles: { name: Stay::Role::ADMIN }).pluck(:email).uniq end |
.ransackable_associations(auth_object = nil) ⇒ Object
49 50 51 |
# File 'app/models/stay/user.rb', line 49 def self.ransackable_associations(auth_object = nil) %w[stay_roles bookings] end |
.ransackable_attributes(auth_object = nil) ⇒ Object
45 46 47 |
# File 'app/models/stay/user.rb', line 45 def self.ransackable_attributes(auth_object = nil) %w[email first_name last_name] end |
Instance Method Details
#full_name ⇒ Object
57 58 59 |
# File 'app/models/stay/user.rb', line 57 def full_name [ first_name, last_name ].compact.join(" ") end |
#has_stay_role?(role_name) ⇒ Boolean
61 62 63 |
# File 'app/models/stay/user.rb', line 61 def has_stay_role?(role_name) stay_roles.exists?(name: role_name) end |
#name ⇒ Object
77 78 79 |
# File 'app/models/stay/user.rb', line 77 def name "#{first_name} #{last_name}" end |
#password_required? ⇒ Boolean
85 86 87 |
# File 'app/models/stay/user.rb', line 85 def password_required? updating_password || super end |
#roles ⇒ Object
53 54 55 |
# File 'app/models/stay/user.rb', line 53 def roles stay_roles end |
#set_default_preferences ⇒ Object
89 90 91 92 |
# File 'app/models/stay/user.rb', line 89 def set_default_preferences self.whatsapp_notification = true if whatsapp_notification.nil? self.sms_notification = false if sms_notification.nil? end |
#stay_admin? ⇒ Boolean
65 66 67 |
# File 'app/models/stay/user.rb', line 65 def stay_admin? has_stay_role?(Stay::Role::ADMIN) end |