Class: Glossarist::Validation::Rules::ConceptContext
- Inherits:
-
Object
- Object
- Glossarist::Validation::Rules::ConceptContext
- Defined in:
- lib/glossarist/validation/rules/concept_context.rb
Overview
Shared context for concept-scoped validation rules.
Provides lazy-memoized access to extracted references so that multiple rules examining the same concept share one extraction pass (DRY, single source of truth). Rules ask the context for references rather than instantiating their own ReferenceExtractor.
Instance Attribute Summary collapse
-
#collection_context ⇒ Object
readonly
Returns the value of attribute collection_context.
-
#concept ⇒ Object
readonly
Returns the value of attribute concept.
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
Instance Method Summary collapse
- #asset_index ⇒ Object
-
#asset_references ⇒ Object
All asset references (NonVerbRep, GraphicalSymbol) extracted from the concept’s model attributes.
- #bibliography_index ⇒ Object
- #concept_id ⇒ Object
- #concept_ids ⇒ Object
- #declared_languages ⇒ Object
- #gcr? ⇒ Boolean
-
#initialize(concept, file_name:, collection_context:) ⇒ ConceptContext
constructor
A new instance of ConceptContext.
- #metadata ⇒ Object
-
#references ⇒ Object
All references extracted from the concept’s text fields (definitions, notes, examples) via {…} mentions, <<xrefs>>, and image::…[] references.
Constructor Details
#initialize(concept, file_name:, collection_context:) ⇒ ConceptContext
Returns a new instance of ConceptContext.
15 16 17 18 19 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 15 def initialize(concept, file_name:, collection_context:) @concept = concept @file_name = file_name @collection_context = collection_context end |
Instance Attribute Details
#collection_context ⇒ Object (readonly)
Returns the value of attribute collection_context.
13 14 15 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 13 def collection_context @collection_context end |
#concept ⇒ Object (readonly)
Returns the value of attribute concept.
13 14 15 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 13 def concept @concept end |
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
13 14 15 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 13 def file_name @file_name end |
Instance Method Details
#asset_index ⇒ Object
47 48 49 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 47 def asset_index @collection_context.asset_index end |
#asset_references ⇒ Object
All asset references (NonVerbRep, GraphicalSymbol) extracted from the concept’s model attributes. Memoized — extracted once per concept, shared across all rules.
38 39 40 41 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 38 def asset_references @asset_references ||= ReferenceExtractor.new .extract_asset_refs_from_concept(@concept) end |
#bibliography_index ⇒ Object
43 44 45 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 43 def bibliography_index @collection_context.bibliography_index end |
#concept_id ⇒ Object
21 22 23 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 21 def concept_id @concept.data&.id&.to_s end |
#concept_ids ⇒ Object
51 52 53 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 51 def concept_ids @collection_context.concept_ids end |
#declared_languages ⇒ Object
55 56 57 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 55 def declared_languages @collection_context.declared_languages end |
#gcr? ⇒ Boolean
63 64 65 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 63 def gcr? @collection_context.gcr? end |
#metadata ⇒ Object
59 60 61 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 59 def @collection_context. end |
#references ⇒ Object
All references extracted from the concept’s text fields (definitions, notes, examples) via {…} mentions, <<xrefs>>, and image::…[] references. Includes ConceptReference, BibliographicReference, and AssetReference objects. Memoized — extracted once per concept, shared across all rules.
30 31 32 33 |
# File 'lib/glossarist/validation/rules/concept_context.rb', line 30 def references @references ||= ReferenceExtractor.new .extract_from_managed_concept(@concept) end |