Class: Avo::SidebarProfileComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/avo/sidebar_profile_component.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods inherited from BaseComponent

#has_with_trial

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#avatarObject



6
7
8
9
10
11
12
# File 'app/components/avo/sidebar_profile_component.rb', line 6

def avatar
  if @user.respond_to?(:avatar) && @user.avatar.present?
    @user.avatar
  else
    ""
  end
end

#can_destroy_user?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/components/avo/sidebar_profile_component.rb', line 38

def can_destroy_user?
  helpers.main_app.respond_to?(destroy_user_session_path)
end

#destroy_user_session_pathObject



32
33
34
35
36
# File 'app/components/avo/sidebar_profile_component.rb', line 32

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

#nameObject



14
15
16
17
18
19
20
21
22
# File 'app/components/avo/sidebar_profile_component.rb', line 14

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

#titleObject



24
25
26
27
28
29
30
# File 'app/components/avo/sidebar_profile_component.rb', line 24

def title
  if @user.respond_to?(:avo_title) && @user.avo_title.present?
    @user.avo_title
  else
    ""
  end
end