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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, field, index) ⇒ Builder

Returns a new instance of Builder.



14
15
16
17
18
# File 'lib/phlexi/field/structure/field_collection.rb', line 14

def initialize(key, field, index)
  @key = key.to_s
  @field = field
  @index = index
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



12
13
14
# File 'lib/phlexi/field/structure/field_collection.rb', line 12

def index
  @index
end

#keyObject (readonly)

Returns the value of attribute key.



12
13
14
# File 'lib/phlexi/field/structure/field_collection.rb', line 12

def key
  @key
end

Instance Method Details

#fieldObject



20
21
22
23
24
# File 'lib/phlexi/field/structure/field_collection.rb', line 20

def field(**)
  @field.class.new(key, **, parent: @field).tap do |field|
    yield field if block_given?
  end
end