Class: Metanorma::Mirror::IdStrategy::Base
- Inherits:
-
Object
- Object
- Metanorma::Mirror::IdStrategy::Base
- Defined in:
- lib/metanorma/mirror/id_strategy.rb
Overview
Base class for ID assignment strategies.
A strategy controls how element IDs are assigned during mirror generation. Subclasses override assign_id and finalize!.
assign_id(element) — called per element during node construction finalize!(document) — called once after the full mirror tree is built
Adding a new strategy = adding a new class. No changes to handlers or the converter (OCP).
Direct Known Subclasses
Instance Method Summary collapse
-
#assign_id(element) ⇒ Object
Returns the ID string to assign to the mirror node for this element.
-
#finalize!(document) ⇒ Object
Post-process the completed mirror document after all IDs are assigned.
Instance Method Details
#assign_id(element) ⇒ Object
Returns the ID string to assign to the mirror node for this element.
21 22 23 |
# File 'lib/metanorma/mirror/id_strategy.rb', line 21 def assign_id(element) SafeAttr.read(element, :id) end |
#finalize!(document) ⇒ Object
Post-process the completed mirror document after all IDs are assigned. Use this to translate cross-reference targets, etc. Returns the (possibly modified) document.
28 29 30 |
# File 'lib/metanorma/mirror/id_strategy.rb', line 28 def finalize!(document) document end |