Module: Lutaml::Model::Schema::XmlCompiler::ElementOrder
- Defined in:
- lib/lutaml/model/schema/xml_compiler/element_order.rb
Overview
Iteration helper for the Lutaml::Xml XSD AST. Wraps the
#element_order array each AST node carries with the special
cases the compiler relies on:
* built-in `Xsd::Base` nodes already produce a resolved order
* `text`-only entries and `<import>` / `<include>` siblings
are skipped
* placeholders in the order are mapped to the matching child
accessor on the node so callers receive concrete AST values.
Class Method Summary collapse
Class Method Details
.resolved(object) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lutaml/model/schema/xml_compiler/element_order.rb', line 18 def resolved(object) return [] if object.element_order.nil? if object.is_a?(Lutaml::Xml::Schema::Xsd::Base) return object.resolved_element_order end object.element_order.each_with_object(object.element_order.dup) do |builder, array| next array.delete(builder) if builder.text? || ELEMENT_ORDER_IGNORABLE.include?(builder.name) index = 0 array.each_with_index do |element, i| next unless element == builder array[i] = Array(object.public_send(Utils.snake_case(builder.name)))[index] index += 1 end end end |