Class: Lutaml::Xml::HoistingAlgorithm::Preserved
- Defined in:
- lib/lutaml/xml/hoisting_algorithm.rb
Overview
Preserved Algorithm
Uses hoisting locations from stored DeclarationPlan. Critical for round-trip fidelity - changing hoist locations could break readers.
If no stored plan or element not found, falls back to provided fallback algorithm.
Instance Attribute Summary collapse
-
#fallback ⇒ Object
readonly
Returns the value of attribute fallback.
Instance Method Summary collapse
-
#initialize(fallback: LCA.new) ⇒ Preserved
constructor
A new instance of Preserved.
- #should_hoist_here?(element, namespace_class, needs, context) ⇒ Boolean
Constructor Details
Instance Attribute Details
#fallback ⇒ Object (readonly)
Returns the value of attribute fallback.
147 148 149 |
# File 'lib/lutaml/xml/hoisting_algorithm.rb', line 147 def fallback @fallback end |
Instance Method Details
#should_hoist_here?(element, namespace_class, needs, context) ⇒ Boolean
154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/lutaml/xml/hoisting_algorithm.rb', line 154 def should_hoist_here?(element, namespace_class, needs, context) stored_plan = context[:stored_plan] if stored_plan && stored_location_exists?(stored_plan, element, namespace_class) # Use stored location stored_declares_here?(stored_plan, element, namespace_class) else # Fall back to configured algorithm fallback.should_hoist_here?(element, namespace_class, needs, context) end end |