Module: Opencdd::Database::Finalization

Included in:
Opencdd::Database
Defined in:
lib/opencdd/database/finalization.rb

Overview

Finalization: link class hierarchy, property↔class links, value-list links, normalize reference collections, rebuild the symbol table.

Instance Method Summary collapse

Instance Method Details

#each_reference_collectionObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/opencdd/database/finalization.rb', line 25

def each_reference_collection
  return enum_for(:each_reference_collection) unless block_given?
  set_property_ids = Opencdd::PropertyIds::REGISTRY
                       .select { |_, e| e.value_kind == :set_of_refs }
                       .keys
  entities.each do |entity|
    set_property_ids.each do |pid|
      raw = entity.properties[pid]
      next if raw.nil? || raw.to_s.strip.empty?
      elements = Opencdd::StructuredValues.unwrap_and_split(raw)
      next if elements.empty?
      yield(entity, pid, raw, elements)
    end
  end
end

#finalize!Object



9
10
11
12
13
14
15
16
# File 'lib/opencdd/database/finalization.rb', line 9

def finalize!
  normalize_reference_collections!
  link_class_hierarchy!
  link_property_classes!
  link_value_lists!
  rebuild_symbol_table!
  self
end

#normalize_reference_collections!Object



18
19
20
21
22
23
# File 'lib/opencdd/database/finalization.rb', line 18

def normalize_reference_collections!
  each_reference_collection do |entity, pid, _raw, elements|
    entity.write_property!(pid, Opencdd::StructuredValues.rejoin(elements))
  end
  self
end

#rebuild_symbol_table!Object



41
42
43
# File 'lib/opencdd/database/finalization.rb', line 41

def rebuild_symbol_table!
  entities.each { |e| register_entity_symbols(e) }
end