Class: Scheming::Attribute::ListBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/scheming/attribute/list_builder.rb

Overview

Attribute Collection Builder

Instance Method Summary collapse

Constructor Details

#initialize(attributes = []) ⇒ ListBuilder

Returns a new instance of ListBuilder.

Parameters:



7
8
9
10
# File 'lib/scheming/attribute/list_builder.rb', line 7

def initialize(attributes = [])
  @attributes = attributes
  freeze
end

Instance Method Details

#attribute(field_name, type:, is_required: true) ⇒ Scheming::Attribute::ListBuilder

Parameters:

Returns:



15
16
17
18
19
20
21
22
# File 'lib/scheming/attribute/list_builder.rb', line 15

def attribute(field_name, type:, is_required: true)
  attr = Scheming::Attribute.new(
    field_name:,
    type:,
    is_required:
  )
  self.class.new(@attributes + [attr])
end

#buildScheming::Attribute::List



25
# File 'lib/scheming/attribute/list_builder.rb', line 25

def build = Scheming::Attribute::List.new(@attributes)