Class: Glossarist::ManagedConceptData

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Includes:
Utilities::CommonFunctions
Defined in:
lib/glossarist/managed_concept_data.rb

Instance Method Summary collapse

Methods included from Utilities::CommonFunctions

#convert_keys_to_snake_case, #slice_keys, #snake_case, #stringify_keys, #symbolize_keys

Instance Method Details

#authoritative_sourceObject



64
65
66
67
68
# File 'lib/glossarist/managed_concept_data.rb', line 64

def authoritative_source
  return [] unless sources

  sources.select(&:authoritative?)
end

#domains_from_yaml(model, value) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/glossarist/managed_concept_data.rb', line 46

def domains_from_yaml(model, value)
  return unless value.is_a?(Array)

  model.domains = value.map do |item|
    if item.is_a?(Hash)
      ConceptReference.of_yaml(item)
    else
      ConceptReference.new(concept_id: item.to_s, ref_type: "domain")
    end
  end
end

#domains_to_yaml(model, doc) ⇒ Object



58
59
60
61
62
# File 'lib/glossarist/managed_concept_data.rb', line 58

def domains_to_yaml(model, doc)
  return if model.domains.nil? || model.domains.empty?

  doc["domains"] = model.domains.map(&:to_hash)
end

#id_from_yaml(model, value) ⇒ Object



32
33
34
# File 'lib/glossarist/managed_concept_data.rb', line 32

def id_from_yaml(model, value)
  model.id = value unless model.id
end

#id_to_yaml(model, doc) ⇒ Object



27
28
29
30
# File 'lib/glossarist/managed_concept_data.rb', line 27

def id_to_yaml(model, doc)
  value = model.id
  doc["identifier"] = value if value && !doc["identifier"]
end

#localizations_from_yaml(model, value) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/glossarist/managed_concept_data.rb', line 36

def localizations_from_yaml(model, value)
  value.each do |localized_concept_hash|
    localized_concept = Glossarist::LocalizedConcept.of_yaml(localized_concept_hash)
    model.localizations.store(localized_concept.language_code,
                              localized_concept)
  end
end

#localizations_to_yaml(model, doc) ⇒ Object



44
# File 'lib/glossarist/managed_concept_data.rb', line 44

def localizations_to_yaml(model, doc); end