Class: YamlExporter::Nodes::ManyPositional

Inherits:
ManyBase
  • Object
show all
Defined in:
lib/yaml_exporter/nodes/many_positional.rb

Overview

many :assoc do ... end — identity is positional (array index). The documented footgun: reordering the YAML list rewrites existing rows in place by index instead of swapping ids.

Instance Attribute Summary

Attributes inherited from ManyBase

#find_by, #name, #owner_class, #positioned_by, #sub_structure

Instance Method Summary collapse

Methods inherited from ManyBase

#build_child, #current_entries, #default_export_order, #destroy_missing, #entry_class, #export, #extra_entry_keys, #extra_entry_schema, #import, #initialize, #phase, #schema_fragment, #sort_for_export, #target_class, #yaml_keys

Constructor Details

This class inherits a constructor from YamlExporter::Nodes::ManyBase

Instance Method Details

#find_or_build_child(parent, _entry, index, existing:) ⇒ Object



9
10
11
# File 'lib/yaml_exporter/nodes/many_positional.rb', line 9

def find_or_build_child(parent, _entry, index, existing:)
  existing[index] || build_child(parent)
end