Class: Glossarist::V3::ManagedConcept

Inherits:
ManagedConcept
  • Object
show all
Defined in:
lib/glossarist/v3/managed_concept.rb

Overview

V3 ManagedConcept.

V3 storage model:

  • Concept metadata lives here on the concept (data, related, dates, sources, status).
  • Hyperedges (PartitiveHyperedge, GenericHyperedge) are PER-FILE: stored at relations//.yaml and loaded via Glossarist::V3::RelationLoader. They are NOT serialized inline on the concept YAML.

This is the v3 clean break — the bundled format (partitive_relations: [...] inline on the concept YAML) is removed. Concept-model removed it without backward compat in commit a62cf85; ruby aligns.

#relations is the unified accessor. The list is populated by callers (GlossaryStore#relations_for, RelationLoader, direct construction). NO typed projections — callers filter:

concept.relations.select { |r| r.is_a?(PartitiveHyperedge) }
concept.relations.select { |r| r.comprehensive.id == my_id }

Instance Method Summary collapse

Instance Method Details

#date_accepted_from_yaml(model, value) ⇒ Object



51
52
53
54
55
# File 'lib/glossarist/v3/managed_concept.rb', line 51

def date_accepted_from_yaml(model, value)
  model.date_accepted = V3::ConceptDate.of_yaml(
    { "date" => value, "type" => "accepted" },
  )
end

#relations=(list) ⇒ Object

Strict setter — rejects duplicates by identity (type + comprehensive + criterion fingerprint). Adding the same hyperedge twice is always a bug; dedupe hides bugs.



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/glossarist/v3/managed_concept.rb', line 60

def relations=(list)
  seen = {}
  Array(list).each do |rel|
    key = hyperedge_identity(rel)
    if seen[key]
      raise ArgumentError,
            "duplicate hyperedge #{key.inspect} — pass each " \
            "decomposition once"
    end
    seen[key] = rel
  end
  super(seen.values)
end