Module: Lutaml::Xml::PlanWalk

Defined in:
lib/lutaml/xml/plan_walk.rb

Overview

Public consumer surface for the plan fast path: one engine parse + descriptor walk and direct model hydration, bypassing the wrapper-tree construction that dominates large-document consumer paths. The returned object is the mapped model root; collection attributes remain collections on that model.

Class Method Summary collapse

Class Method Details

.call(model_class, xml, _options = {}) ⇒ Object

Build the plan, walk the document, and hydrate the mapped root. Returns nil when the model is not plan-compilable.



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/lutaml/xml/plan_walk.rb', line 14

def call(model_class, xml, _options = {})
  register = Lutaml::Model::Config.default_register
  plan = PlanCompiler.compile(model_class, register)
  return nil unless plan

  document = ::Leptris::XML.parse(xml)
  root = document.root
  return nil unless root && root.name == plan[:tree][:name]

  PlanHydrator.call(model_class, plan,
                    plan[:descriptor].walk(root),
                    node: root)
end