Class: Solrengine::Ui::WalletButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Solrengine::Ui::WalletButtonComponent
- Defined in:
- app/components/solrengine/ui/wallet_button_component.rb
Instance Attribute Summary collapse
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#login_path ⇒ Object
readonly
Returns the value of attribute login_path.
-
#logout_path ⇒ Object
readonly
Returns the value of attribute logout_path.
Instance Method Summary collapse
- #connected? ⇒ Boolean
-
#initialize(current_user: nil, login_path: "/auth/login", logout_path: "/auth/logout") ⇒ WalletButtonComponent
constructor
A new instance of WalletButtonComponent.
- #truncated_address ⇒ Object
Constructor Details
#initialize(current_user: nil, login_path: "/auth/login", logout_path: "/auth/logout") ⇒ WalletButtonComponent
Returns a new instance of WalletButtonComponent.
8 9 10 11 12 |
# File 'app/components/solrengine/ui/wallet_button_component.rb', line 8 def initialize(current_user: nil, login_path: "/auth/login", logout_path: "/auth/logout") @current_user = current_user @login_path = login_path @logout_path = logout_path end |
Instance Attribute Details
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
6 7 8 |
# File 'app/components/solrengine/ui/wallet_button_component.rb', line 6 def current_user @current_user end |
#login_path ⇒ Object (readonly)
Returns the value of attribute login_path.
6 7 8 |
# File 'app/components/solrengine/ui/wallet_button_component.rb', line 6 def login_path @login_path end |
#logout_path ⇒ Object (readonly)
Returns the value of attribute logout_path.
6 7 8 |
# File 'app/components/solrengine/ui/wallet_button_component.rb', line 6 def logout_path @logout_path end |
Instance Method Details
#connected? ⇒ Boolean
14 15 16 |
# File 'app/components/solrengine/ui/wallet_button_component.rb', line 14 def connected? current_user.present? end |
#truncated_address ⇒ Object
18 19 20 21 22 23 |
# File 'app/components/solrengine/ui/wallet_button_component.rb', line 18 def truncated_address address = current_user.wallet_address return "" if address.nil? || address.length < 8 "#{address[0..3]}...#{address[-4..]}" end |