Class: Phlexi::Field::Structure::FieldCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/phlexi/field/structure/field_collection.rb

Direct Known Subclasses

Builder::FieldCollection

Defined Under Namespace

Classes: Builder

Instance Method Summary collapse

Constructor Details

#initialize(field:, collection:) ⇒ FieldCollection

Returns a new instance of FieldCollection.



27
28
29
30
31
# File 'lib/phlexi/field/structure/field_collection.rb', line 27

def initialize(field:, collection:, &)
  @field = field
  @collection = build_collection(collection)
  each(&) if block_given?
end

Instance Method Details

#eachObject



33
34
35
36
37
# File 'lib/phlexi/field/structure/field_collection.rb', line 33

def each(&)
  @collection.each.with_index do |item, index|
    yield self.class::Builder.new(item, @field, index)
  end
end