Class: Anchor::CheckBoxCollectionComponent
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Anchor::CheckBoxCollectionComponent
- Defined in:
- app/components/anchor/check_box_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
- #check_box(check_box:) ⇒ Object
-
#initialize(form_builder:, attribute:, collection:, value_method:, text_method:, descriptions: nil, **options) ⇒ CheckBoxCollectionComponent
constructor
A new instance of CheckBoxCollectionComponent.
- #options ⇒ 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) ⇒ CheckBoxCollectionComponent
Returns a new instance of CheckBoxCollectionComponent.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/anchor/check_box_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/check_box_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/check_box_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/check_box_collection_component.rb', line 3 def form_builder @form_builder end |
Instance Method Details
#check_box(check_box:) ⇒ Object
31 32 33 |
# File 'app/components/anchor/check_box_collection_component.rb', line 31 def check_box(check_box:) CheckBoxComponent.new(check_box:, attribute:, form_builder:) end |
#options ⇒ Object
25 26 27 28 29 |
# File 'app/components/anchor/check_box_collection_component.rb', line 25 def @options.merge( class: Array(@options.delete(:class)) + CheckBoxComponent::INPUT_CLASSES ) end |