Class: Glossarist::ConceptReference

Inherits:
Lutaml::Model::Serializable
  • Object
show all
Includes:
Reference
Defined in:
lib/glossarist/concept_reference.rb

Overview

A typed reference to another concept, either local (within the same glossary) or external (in another concept registry).

Local references use concept_id without source. External references use source (a registry URN prefix) and concept_id to identify the target concept, or a direct urn field for formal URN references.

Includes the Reference protocol. Overrides cite?, local?, and external? because ConceptReference is the only reference kind whose predicates depend on runtime state (ref_type, source).

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.domain(concept_id) ⇒ Object



33
34
35
# File 'lib/glossarist/concept_reference.rb', line 33

def self.domain(concept_id)
  new(concept_id: concept_id, ref_type: "domain")
end

.section(concept_id) ⇒ Object



37
38
39
# File 'lib/glossarist/concept_reference.rb', line 37

def self.section(concept_id)
  new(concept_id: concept_id, ref_type: "section")
end

Instance Method Details

#cite?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/glossarist/concept_reference.rb', line 50

def cite?
  ref_type == "cite"
end

#dedup_keyObject



54
55
56
# File 'lib/glossarist/concept_reference.rb', line 54

def dedup_key
  concept_id ? [source, concept_id] : [source, concept_id, term]
end

#external?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/glossarist/concept_reference.rb', line 46

def external?
  !local?
end

#local?Boolean

Returns:

  • (Boolean)


41
42
43
44
# File 'lib/glossarist/concept_reference.rb', line 41

def local?
  %w[local designation cite].include?(ref_type) ||
    (ref_type.nil? && (source.nil? || source.empty?))
end