Class: Glossarist::ConceptRef
- Inherits:
-
Lutaml::Model::Serializable
- Object
- Lutaml::Model::Serializable
- Glossarist::ConceptRef
- Defined in:
- lib/glossarist/concept_ref.rb
Overview
A typed reference to another concept, used inside n-ary relation members and other internal pointer shapes.
The base ConceptRef carries source, id, and text. The richer
ConceptReference (in glossarist/concept_reference.rb) extends
this with term, urn, version, ref_type for use in
cross-vocabulary references and relevance contexts.
A ConceptRef is identified by source:id for external references
or just id for local references. The qualified_id class method
is the single SSOT for this string format — used by RelationLoader,
the RDF transform, and ConceptRef-bearing data structures.
Direct Known Subclasses
Class Method Summary collapse
-
.qualified_id(ref) ⇒ Object
SSOT for the canonical "qualified identifier" string of a ConceptRef.
Instance Method Summary collapse
-
#qualified_id ⇒ Object
Per-instance convenience delegating to the class method.
-
#same_concept?(other) ⇒ Boolean
True iff
otherrefers to the same concept as self.
Class Method Details
.qualified_id(ref) ⇒ Object
SSOT for the canonical "qualified identifier" string of a ConceptRef. Returns:
- "{source}:{id}" when both source and id are present
- "{id}" when only id is present (local ref)
- "{source}:{text}" when source and text are present (no id)
- "{text}" when only text is present (external
concept form, no resolvable id)
- nil when the ref is empty / not a ConceptRef
Two refs are considered to point at the same concept iff their qualified_id is equal. Tables and registries can use this directly as a hash key.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/glossarist/concept_ref.rb', line 40 def self.qualified_id(ref) return nil unless ref.is_a?(ConceptRef) id_part = (ref.id.to_s.empty? ? nil : ref.id) text_part = (ref.text.to_s.empty? ? nil : ref.text) source_part = (ref.source.to_s.empty? ? nil : ref.source) if id_part source_part ? "#{source_part}:#{id_part}" : id_part elsif text_part source_part ? "#{source_part}:#{text_part}" : text_part end end |
Instance Method Details
#qualified_id ⇒ Object
Per-instance convenience delegating to the class method.
55 56 57 |
# File 'lib/glossarist/concept_ref.rb', line 55 def qualified_id self.class.qualified_id(self) end |
#same_concept?(other) ⇒ Boolean
True iff other refers to the same concept as self.
60 61 62 |
# File 'lib/glossarist/concept_ref.rb', line 60 def same_concept?(other) qualified_id == self.class.qualified_id(other) end |