Class: Forms::CollectionCheckBoxBuilder
- Inherits:
-
Object
- Object
- Forms::CollectionCheckBoxBuilder
- Defined in:
- lib/forms/collection_check_box_builder.rb
Overview
Yielded for each item by Form#collection_check_boxes. Provides check_box and label builders mirroring Rails' collection_check_boxes API.
Instance Attribute Summary collapse
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #check_box(options = {}) ⇒ Object
-
#initialize(object:, value:, text:, checked:, name:, id:) ⇒ CollectionCheckBoxBuilder
constructor
A new instance of CollectionCheckBoxBuilder.
- #label(options = {}) ⇒ Object
Constructor Details
#initialize(object:, value:, text:, checked:, name:, id:) ⇒ CollectionCheckBoxBuilder
Returns a new instance of CollectionCheckBoxBuilder.
9 10 11 12 13 14 15 16 |
# File 'lib/forms/collection_check_box_builder.rb', line 9 def initialize(object:, value:, text:, checked:, name:, id:) @object = object @value = value @text = text @checked = checked @name = name @id = id end |
Instance Attribute Details
#object ⇒ Object (readonly)
Returns the value of attribute object.
7 8 9 |
# File 'lib/forms/collection_check_box_builder.rb', line 7 def object @object end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
7 8 9 |
# File 'lib/forms/collection_check_box_builder.rb', line 7 def text @text end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
7 8 9 |
# File 'lib/forms/collection_check_box_builder.rb', line 7 def value @value end |
Instance Method Details
#check_box(options = {}) ⇒ Object
18 19 20 |
# File 'lib/forms/collection_check_box_builder.rb', line 18 def check_box( = {}) Forms::CollectionCheckBox.new(name: @name, id: @id, value: @value, checked: @checked, **) end |
#label(options = {}) ⇒ Object
22 23 24 |
# File 'lib/forms/collection_check_box_builder.rb', line 22 def label( = {}, &) Forms::CollectionLabel.new(for_id: @id, text: @text, **, &) end |