Class: Ecoportal::API::GraphQL::Model::Template::CommandSynthesis
- Inherits:
-
Object
- Object
- Ecoportal::API::GraphQL::Model::Template::CommandSynthesis
- Defined in:
- lib/ecoportal/api/graphql/model/template/command_synthesis.rb
Overview
Diff engine: walks the in-memory tree and emits the ordered [CommandInput] batch
#as_commands returns, plus the phase-scoped subsets StagedExecutor sends one at
a time (each subset re-synthesised against the CURRENT tree, so a node resolved by
an earlier phase — Node#resolve! — is addressed by its real id, not its stale
placeholder, the next time a phase is built; see Node#ref).
ORDER — stage -> section -> field -> option/config -> force -> helper -> binding,
matching Diff::CommandSynthesizer::KIND_ORDER's own dependency-safe order plus the
two groups it does not cover (force, helper/binding — no existing gem emitter
before this class). Within a stage: structural section commands first
(add/remove/header), THEN a reorderSection TRAILER for every section with a
pending move (see Section#move's own doc for why last) — this mirrors the
EPT-2078 "preserve reorderSection trailer protection" rule.
SAFETY — never guesses. A field's field_type has no setter (see Field's own
doc), so a type "change" cannot even be expressed here; every other write goes
through the same WorkflowCommand.build layer Builder::TemplateBuilder and
Diff::CommandSynthesizer already use, so a missing required key (value on a
new option, etc.) raises there — never invented here.
Instance Method Summary collapse
-
#commands ⇒ Object
The full ordered batch — the public
#as_commandscontract. - #field_phase ⇒ Object
- #force_phase ⇒ Object
- #helper_binding_phase ⇒ Object
-
#initialize(instance) ⇒ CommandSynthesis
constructor
A new instance of CommandSynthesis.
- #section_phase ⇒ Object
-
#stage_phase ⇒ Object
--- phase-scoped subsets, used by StagedExecutor -------------------.
Constructor Details
#initialize(instance) ⇒ CommandSynthesis
Returns a new instance of CommandSynthesis.
26 27 28 |
# File 'lib/ecoportal/api/graphql/model/template/command_synthesis.rb', line 26 def initialize(instance) @instance = instance end |
Instance Method Details
#commands ⇒ Object
The full ordered batch — the public #as_commands contract.
31 32 33 |
# File 'lib/ecoportal/api/graphql/model/template/command_synthesis.rb', line 31 def commands stage_phase + section_phase + field_phase + force_phase + helper_binding_phase end |
#field_phase ⇒ Object
45 46 47 |
# File 'lib/ecoportal/api/graphql/model/template/command_synthesis.rb', line 45 def field_phase instance.stages.flat_map { |stage| stage.sections.flat_map { |section| field_commands_for_section(section) } } end |
#force_phase ⇒ Object
49 50 51 52 53 54 |
# File 'lib/ecoportal/api/graphql/model/template/command_synthesis.rb', line 49 def force_phase instance.stages.flat_map { |stage| stage.forces.reject(&:new?).flat_map { |f| force_edit_commands(f) } + stage.forces.select(&:new?).flat_map { |f| force_add_commands(f) } } end |
#helper_binding_phase ⇒ Object
56 57 58 |
# File 'lib/ecoportal/api/graphql/model/template/command_synthesis.rb', line 56 def helper_binding_phase instance.stages.flat_map { |stage| stage.forces.flat_map { |force| helper_and_binding_commands(force) } } end |
#section_phase ⇒ Object
41 42 43 |
# File 'lib/ecoportal/api/graphql/model/template/command_synthesis.rb', line 41 def section_phase instance.stages.flat_map { |stage| section_commands_for_stage(stage) } end |
#stage_phase ⇒ Object
--- phase-scoped subsets, used by StagedExecutor -------------------
37 38 39 |
# File 'lib/ecoportal/api/graphql/model/template/command_synthesis.rb', line 37 def stage_phase instance.stages.select(&:new?).flat_map { |stage| stage_commands(stage) } end |