Class: Eco::API::UseCases::GraphQL::Samples::Pages::Template::CommandEmitter::SectionBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/eco/api/usecases/graphql/samples/pages/template/command_emitter.rb

Instance Method Summary collapse

Constructor Details

#initialize(emitter, stage_id, section_id) ⇒ SectionBuilder

Returns a new instance of SectionBuilder.



89
90
91
92
93
# File 'lib/eco/api/usecases/graphql/samples/pages/template/command_emitter.rb', line 89

def initialize(emitter, stage_id, section_id)
  @emitter    = emitter
  @stage_id   = stage_id
  @section_id = section_id
end

Instance Method Details

#field(label:, field_type:, column: 0, description: nil, required: nil, &block) ⇒ Object

description / required are accepted for forward-compatibility with the CSV-build identity convention (hidden-field + description). NOTE: the RELEASED gem's addField input (Input::WorkflowCommand::AddField::VALID_KEYS) currently slices to placeholderId/fieldType/label/stageId/sectionId/column and compacts everything else away — so today these pass-throughs are DROPPED by the gem contract (harmless no-op). They are wired here so that, once the gem's addField gains a description key, no emitter change is needed.



101
102
103
104
105
106
107
108
# File 'lib/eco/api/usecases/graphql/samples/pages/template/command_emitter.rb', line 101

def field(label:, field_type:, column: 0, description: nil, required: nil, &block)
  field_id = @emitter.allocate(:fld)
  @emitter.emit(:addField, placeholderId: field_id, fieldType: field_type, label: label,
                           stageId: @stage_id, sectionId: @section_id, column: column,
                           description: description, required: required)
  FieldBuilder.new(@emitter, field_id).tap { |b| block&.call(b) }
  field_id
end