Class: Forms::CollectionCheckBoxBuilder

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#objectObject (readonly)

Returns the value of attribute object.



7
8
9
# File 'lib/forms/collection_check_box_builder.rb', line 7

def object
  @object
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'lib/forms/collection_check_box_builder.rb', line 7

def text
  @text
end

#valueObject (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(options = {})
  Forms::CollectionCheckBox.new(name: @name, id: @id, value: @value, checked: @checked, **options)
end

#label(options = {}) ⇒ Object



22
23
24
# File 'lib/forms/collection_check_box_builder.rb', line 22

def label(options = {}, &)
  Forms::CollectionLabel.new(for_id: @id, text: @text, **options, &)
end