Class: Superform::FieldCollection
- Inherits:
-
Object
- Object
- Superform::FieldCollection
- Includes:
- Enumerable
- Defined in:
- lib/superform.rb
Instance Method Summary collapse
- #each ⇒ Object
- #field ⇒ Object
-
#initialize(field:) ⇒ FieldCollection
constructor
A new instance of FieldCollection.
- #values ⇒ Object
Constructor Details
#initialize(field:) ⇒ FieldCollection
Returns a new instance of FieldCollection.
234 235 236 237 238 |
# File 'lib/superform.rb', line 234 def initialize(field:, &) @field = field @index = 0 each(&) if block_given? end |
Instance Method Details
#each ⇒ Object
240 241 242 243 244 |
# File 'lib/superform.rb', line 240 def each(&) values.each do |value| yield build_field(value: value) end end |
#field ⇒ Object
246 247 248 |
# File 'lib/superform.rb', line 246 def field build_field end |
#values ⇒ Object
250 251 252 |
# File 'lib/superform.rb', line 250 def values Array(@field.value) end |