Class: Jav::SidebarProfileComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Jav::SidebarProfileComponent
- Defined in:
- app/components/jav/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 9 |
# File 'app/components/jav/sidebar_profile_component.rb', line 6 def initialize(user:) super @user = user end |
Instance Attribute Details
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'app/components/jav/sidebar_profile_component.rb', line 4 def user @user end |
Instance Method Details
#avatar ⇒ Object
11 12 13 14 15 16 17 |
# File 'app/components/jav/sidebar_profile_component.rb', line 11 def avatar if user.respond_to?(:avatar) && user.avatar.present? user.avatar else "" end end |
#can_destroy_user? ⇒ Boolean
43 44 45 |
# File 'app/components/jav/sidebar_profile_component.rb', line 43 def can_destroy_user? helpers.main_app.respond_to?(destroy_user_session_path) end |
#destroy_user_session_path ⇒ Object
37 38 39 40 41 |
# File 'app/components/jav/sidebar_profile_component.rb', line 37 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`. (Jav.configuration.sign_out_path_name || "destroy_#{Jav.configuration.current_user_resource_name}_session_path").to_sym end |
#name ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'app/components/jav/sidebar_profile_component.rb', line 19 def name if user.respond_to?(:name) && user.name.present? user.name elsif user.respond_to?(:email) && user.email.present? user.email else "Jav user" end end |
#title ⇒ Object
29 30 31 32 33 34 35 |
# File 'app/components/jav/sidebar_profile_component.rb', line 29 def title if user.respond_to?(:jav_title) && user.jav_title.present? user.jav_title else "" end end |