Class: Avo::SidebarProfileComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Avo::SidebarProfileComponent
- Defined in:
- app/components/avo/sidebar_profile_component.rb
Instance Attribute Summary collapse
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Instance Method Summary collapse
- #avatar ⇒ Object
- #can_destroy_user? ⇒ Boolean
- #destroy_user_session_path ⇒ Object
-
#initialize(user:) ⇒ SidebarProfileComponent
constructor
A new instance of SidebarProfileComponent.
- #name ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(user:) ⇒ SidebarProfileComponent
Returns a new instance of SidebarProfileComponent.
6 7 8 |
# File 'app/components/avo/sidebar_profile_component.rb', line 6 def initialize(user:) @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'app/components/avo/sidebar_profile_component.rb', line 4 def user @user end |
Instance Method Details
#avatar ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/components/avo/sidebar_profile_component.rb', line 10 def avatar if user.respond_to?(:avatar) && user.avatar.present? user.avatar else "" end end |
#can_destroy_user? ⇒ Boolean
42 43 44 |
# File 'app/components/avo/sidebar_profile_component.rb', line 42 def can_destroy_user? helpers.main_app.respond_to?(destroy_user_session_path) end |
#destroy_user_session_path ⇒ Object
36 37 38 39 40 |
# File 'app/components/avo/sidebar_profile_component.rb', line 36 def destroy_user_session_path # If `sign_out_path_name` is configured, use it. Otherwise construct the # path name based on `current_user_resource_name`. (Avo.configuration.sign_out_path_name || "destroy_#{Avo.configuration.current_user_resource_name}_session_path").to_sym end |
#name ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'app/components/avo/sidebar_profile_component.rb', line 18 def name if user.respond_to?(:name) && user.name.present? user.name elsif user.respond_to?(:email) && user.email.present? user.email else "Avo user" end end |
#title ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/components/avo/sidebar_profile_component.rb', line 28 def title if user.respond_to?(:avo_title) && user.avo_title.present? user.avo_title else "" end end |