Class: Idml::Composition::InsertIdml
- Inherits:
-
Object
- Object
- Idml::Composition::InsertIdml
- Defined in:
- lib/idml/composition/insert_idml.rb
Overview
Insert one package's structural content into another. Both packages are prefixed first to avoid Self collisions; then the source's BackingStory XMLElement tree is appended to the destination's, and the source's Stories are added to the destination's package. The merge goes through the typed BackingStory model — no ad-hoc XML libraries.
Defined Under Namespace
Classes: BackingStoryMerger
Instance Method Summary collapse
- #call(source:) ⇒ Object
-
#initialize(package) ⇒ InsertIdml
constructor
A new instance of InsertIdml.
Constructor Details
#initialize(package) ⇒ InsertIdml
Returns a new instance of InsertIdml.
12 13 14 |
# File 'lib/idml/composition/insert_idml.rb', line 12 def initialize(package) @package = package end |
Instance Method Details
#call(source:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/idml/composition/insert_idml.rb', line 16 def call(source:) dest_prefixed = Prefix.new(@package).call(prefix: "dest_") source_prefixed = Prefix.new(source).call(prefix: "src_") parts = dest_prefixed.each_part.to_a.to_h { |n, c| [n, c] } merge_backing_story!(parts, dest_prefixed, source_prefixed) merge_stories!(parts, source_prefixed) merge_spreads!(parts, source_prefixed) rewrite_designmap!(parts, source_prefixed) write_merged(parts) end |