Class: Lutaml::Lml::ViewResolution
- Inherits:
-
Object
- Object
- Lutaml::Lml::ViewResolution
- Defined in:
- lib/lutaml/lml/view_resolution.rb
Overview
Post-parse step: expand view imports, apply show/hide filters, rebuild the document's entity collections, and enrich association labels. Import expansion runs only when the document declares view imports; label enrichment always runs.
Class Method Summary collapse
- .call(document, base_dir) ⇒ Object
- .rebuild_document(document, entities, associations) ⇒ Object
- .resolve_imports(document, base_dir) ⇒ Object
Class Method Details
.call(document, base_dir) ⇒ Object
10 11 12 13 |
# File 'lib/lutaml/lml/view_resolution.rb', line 10 def self.call(document, base_dir) document = resolve_imports(document, base_dir) if document.view_imports.any? AssociationLabelResolver.new.enrich(document) end |
.rebuild_document(document, entities, associations) ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/lutaml/lml/view_resolution.rb', line 21 def self.rebuild_document(document, entities, associations) grouped = entities.group_by { |e| e.class.entity_type } EntityTypes.symbols.each do |symbol| document.public_send("#{symbol}=", grouped[symbol] || []) end document.associations = associations document end |
.resolve_imports(document, base_dir) ⇒ Object
15 16 17 18 19 |
# File 'lib/lutaml/lml/view_resolution.rb', line 15 def self.resolve_imports(document, base_dir) entity_index, associations = ImportResolver.new(base_dir).resolve(document) entities, associations = ViewResolver.new.resolve(document, entity_index, associations) rebuild_document(document, entities, associations) end |