Class: Panda::Core::Admin::SecretFieldComponent
- Defined in:
- app/components/panda/core/admin/secret_field_component.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary collapse
-
#masked ⇒ Object
readonly
Returns the value of attribute masked.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #button_classes ⇒ Object
- #display_value ⇒ Object
-
#initialize(value:, masked: true, **attrs) ⇒ SecretFieldComponent
constructor
A new instance of SecretFieldComponent.
Constructor Details
#initialize(value:, masked: true, **attrs) ⇒ SecretFieldComponent
Returns a new instance of SecretFieldComponent.
7 8 9 10 11 |
# File 'app/components/panda/core/admin/secret_field_component.rb', line 7 def initialize(value:, masked: true, **attrs) @value = value @masked = masked super(**attrs) end |
Instance Attribute Details
#masked ⇒ Object (readonly)
Returns the value of attribute masked.
13 14 15 |
# File 'app/components/panda/core/admin/secret_field_component.rb', line 13 def masked @masked end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
13 14 15 |
# File 'app/components/panda/core/admin/secret_field_component.rb', line 13 def value @value end |
Instance Method Details
#button_classes ⇒ Object
25 26 27 |
# File 'app/components/panda/core/admin/secret_field_component.rb', line 25 def "shrink-0 btn btn-secondary transition" end |
#display_value ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'app/components/panda/core/admin/secret_field_component.rb', line 15 def display_value return value unless masked && value.present? if value.length > 4 "\u2022" * 12 + value[-4..] else "\u2022" * value.length end end |