Class: Protoform::FieldCollection
- Inherits:
-
Object
- Object
- Protoform::FieldCollection
- Includes:
- Enumerable
- Defined in:
- lib/protoform/field_collection.rb
Instance Method Summary collapse
- #each ⇒ Object
- #field ⇒ Object
-
#initialize(field:, &block) ⇒ FieldCollection
constructor
A new instance of FieldCollection.
- #values ⇒ Object
Constructor Details
#initialize(field:, &block) ⇒ FieldCollection
Returns a new instance of FieldCollection.
7 8 9 10 11 |
# File 'lib/protoform/field_collection.rb', line 7 def initialize(field:, &block) @field = field @index = 0 each(&block) if block end |
Instance Method Details
#each ⇒ Object
13 14 15 16 17 18 19 |
# File 'lib/protoform/field_collection.rb', line 13 def each Enumerator.new do |collection| values.each do |value| collection.yield build_field(value:) end end end |
#field ⇒ Object
21 22 23 |
# File 'lib/protoform/field_collection.rb', line 21 def field build_field end |
#values ⇒ Object
25 26 27 |
# File 'lib/protoform/field_collection.rb', line 25 def values Array(@field.value) end |