Class: Anchor::RadioButtonCollectionComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Anchor::RadioButtonCollectionComponent
- Defined in:
- app/components/anchor/radio_button_collection_component.rb
Constant Summary
Constants included from ViewHelper
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#descriptions ⇒ Object
readonly
Returns the value of attribute descriptions.
-
#form_builder ⇒ Object
readonly
Returns the value of attribute form_builder.
Instance Method Summary collapse
-
#initialize(form_builder:, attribute:, collection:, value_method:, text_method:, descriptions: nil, **options) ⇒ RadioButtonCollectionComponent
constructor
A new instance of RadioButtonCollectionComponent.
- #options ⇒ Object
- #radio(radio:) ⇒ Object
Methods inherited from Component
Methods included from ViewHelper
#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes
Methods included from FetchOrFallbackHelper
Constructor Details
#initialize(form_builder:, attribute:, collection:, value_method:, text_method:, descriptions: nil, **options) ⇒ RadioButtonCollectionComponent
Returns a new instance of RadioButtonCollectionComponent.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/anchor/radio_button_collection_component.rb', line 5 def initialize( form_builder:, attribute:, collection:, value_method:, text_method:, descriptions: nil, ** ) @form_builder = form_builder @attribute = attribute @collection = collection @value_method = value_method @text_method = text_method @descriptions = descriptions @options = super() end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
3 4 5 |
# File 'app/components/anchor/radio_button_collection_component.rb', line 3 def attribute @attribute end |
#descriptions ⇒ Object (readonly)
Returns the value of attribute descriptions.
3 4 5 |
# File 'app/components/anchor/radio_button_collection_component.rb', line 3 def descriptions @descriptions end |
#form_builder ⇒ Object (readonly)
Returns the value of attribute form_builder.
3 4 5 |
# File 'app/components/anchor/radio_button_collection_component.rb', line 3 def form_builder @form_builder end |
Instance Method Details
#options ⇒ Object
25 26 27 28 29 30 |
# File 'app/components/anchor/radio_button_collection_component.rb', line 25 def @options.merge( class: Array(@options.delete(:class)) + RadioButtonComponent::INPUT_CLASSES ) end |
#radio(radio:) ⇒ Object
32 33 34 35 36 37 38 |
# File 'app/components/anchor/radio_button_collection_component.rb', line 32 def radio(radio:) RadioButtonComponent.new( radio:, attribute:, form_builder: ) end |