Module: Lutaml::Xml::Serialization::ModelImportExt

Defined in:
lib/lutaml/xml/serialization/model_import_ext.rb

Overview

XML-specific overrides for ModelImport methods.

Prepended into Serialize::ModelImport when XML is loaded. Provides XML-specific implementations for:

  • root? (checks XML mapping for root element)

  • ensure_format_mapping_imports! (resolves XML mapping imports)

  • collection_with_conflicting_sort? (checks XML ordered? vs sort_by)

Instance Method Summary collapse

Instance Method Details

#collection_with_conflicting_sort?Boolean

Check for conflicting sort configurations with XML ordered mapping

Returns:

  • (Boolean)

    True if there’s a conflict



32
33
34
35
36
# File 'lib/lutaml/xml/serialization/model_import_ext.rb', line 32

def collection_with_conflicting_sort?
  self <= Lutaml::Model::Collection &&
    @mappings[:xml]&.ordered? &&
    !!@sort_by_field
end

#ensure_format_mapping_imports!(register = nil) ⇒ Object

Resolve XML mapping imports

Parameters:

  • register (Symbol, nil) (defaults to: nil)

    The register context



25
26
27
# File 'lib/lutaml/xml/serialization/model_import_ext.rb', line 25

def ensure_format_mapping_imports!(register = nil)
  mappings[:xml]&.ensure_mappings_imported!(register)
end

#root?(register = nil) ⇒ Boolean

Check if register has an XML root mapping

Parameters:

  • register (Symbol, nil) (defaults to: nil)

    The register to check

Returns:

  • (Boolean)

    True if the model has an XML root mapping



18
19
20
# File 'lib/lutaml/xml/serialization/model_import_ext.rb', line 18

def root?(register = nil)
  mappings_for(:xml, register)&.root? || false
end