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



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

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

#can_sign_out_user?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/components/avo/sidebar_profile_component.rb', line 53

def can_sign_out_user?
  sign_out_path.present? && main_app.respond_to?(sign_out_path&.to_sym)
end

#default_sign_out_pathObject



47
48
49
50
51
# File 'app/components/avo/sidebar_profile_component.rb', line 47

def default_sign_out_path
  default_path = :"destroy_#{Avo.configuration.current_user_resource_name}_session_path"

  default_path if main_app.respond_to?(default_path)
end

#nameObject



16
17
18
19
20
21
22
23
24
25
26
# File 'app/components/avo/sidebar_profile_component.rb', line 16

def name
  if @user.respond_to?(:name) && @user.name.present?
    @user.name
  elsif @user.respond_to?(:email) && @user.email.present?
    @user.email
  elsif @user.respond_to?(:email_address) && @user.email_address.present?
    @user.email_address
  else
    "Avo user"
  end
end

#sign_out_methodObject



36
37
38
# File 'app/components/avo/sidebar_profile_component.rb', line 36

def sign_out_method
  :delete
end

#sign_out_pathObject



40
41
42
43
44
45
# File 'app/components/avo/sidebar_profile_component.rb', line 40

def sign_out_path
  return Avo.configuration.sign_out_path_name if Avo.configuration.sign_out_path_name.present?
  return :session_path if helpers.possibly_rails_authentication?

  default_sign_out_path
end

#titleObject



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