Class: ViewComponent::Form::HintComponent
- Inherits:
-
FieldComponent
- Object
- BaseComponent
- FieldComponent
- ViewComponent::Form::HintComponent
- Defined in:
- app/components/view_component/form/hint_component.rb
Instance Attribute Summary collapse
-
#attribute_content ⇒ Object
readonly
Returns the value of attribute attribute_content.
Attributes inherited from FieldComponent
Attributes inherited from BaseComponent
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(form, object_name, method_name, content_or_options = nil, options = nil) ⇒ HintComponent
constructor
A new instance of HintComponent.
- #render? ⇒ Boolean
Methods inherited from FieldComponent
#label_text, #method_errors, #method_errors?, #object_method_names, #optional?, #required?, #validators, #value
Methods inherited from BaseComponent
#html_class, #object_errors, #object_errors?
Methods included from ClassNamesHelper
#build_tag_values, #class_names
Constructor Details
#initialize(form, object_name, method_name, content_or_options = nil, options = nil) ⇒ HintComponent
Returns a new instance of HintComponent.
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/components/view_component/form/hint_component.rb', line 12 def initialize(form, object_name, method_name, = nil, = nil) ||= {} = .is_a?(Hash) if .merge! @attribute_content = nil else @attribute_content = end super(form, object_name, method_name, ) end |
Instance Attribute Details
#attribute_content ⇒ Object (readonly)
Returns the value of attribute attribute_content.
8 9 10 |
# File 'app/components/view_component/form/hint_component.rb', line 8 def attribute_content @attribute_content end |
Instance Method Details
#call ⇒ Object
26 27 28 29 30 |
# File 'app/components/view_component/form/hint_component.rb', line 26 def call = content.presence || attribute_content.presence tag.public_send(self.class.tag, , **) end |
#render? ⇒ Boolean
32 33 34 |
# File 'app/components/view_component/form/hint_component.rb', line 32 def render? content.present? || attribute_content.present? end |