Class: Coradoc::Reference::Resolution

Inherits:
Object
  • Object
show all
Defined in:
lib/coradoc/reference/resolution.rb

Overview

Orchestrator: resolves every Edge in the tree via the Resolver, enforces the missing/ambiguous policies, and — only when asked to materialize — rebuilds the tree with rendered inline nodes via the Presentation layout and the Materializer registry.

Two-step contract:

  • materialize: false validates references and returns the INPUT document (never mutated, never copied).
  • materialize: true returns a NEW document. Untouched subtrees are shared with the input (structural sharing) — treat both as immutable.

Wired from the public API Coradoc.resolve_references.

Defined Under Namespace

Classes: ReplaceWalker

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(catalog:, presentation:, missing:, ambiguous:, materialize:, resolver: nil, format: nil, materializer_registry: default_registry) ⇒ Resolution

Returns a new instance of Resolution.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/coradoc/reference/resolution.rb', line 23

def initialize(catalog:, presentation:, missing:, ambiguous:,
               materialize:, resolver: nil, format: nil,
               materializer_registry: default_registry)
  @catalog = catalog
  @presentation = presentation
  @missing_policy = missing
  @ambiguous_policy = ambiguous
  @materialize_policy = materialize
  @format = format
  @materializer_registry = materializer_registry
  @resolver = resolver || Resolver::Catalog.new(
    catalog: catalog, ambiguous: ambiguous, missing: missing
  )
end

Instance Attribute Details

#ambiguous_policyObject (readonly)

Returns the value of attribute ambiguous_policy.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def ambiguous_policy
  @ambiguous_policy
end

#catalogObject (readonly)

Returns the value of attribute catalog.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def catalog
  @catalog
end

#formatObject (readonly)

Returns the value of attribute format.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def format
  @format
end

#materialize_policyObject (readonly)

Returns the value of attribute materialize_policy.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def materialize_policy
  @materialize_policy
end

#materializer_registryObject (readonly)

Returns the value of attribute materializer_registry.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def materializer_registry
  @materializer_registry
end

#missing_policyObject (readonly)

Returns the value of attribute missing_policy.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def missing_policy
  @missing_policy
end

#presentationObject (readonly)

Returns the value of attribute presentation.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def presentation
  @presentation
end

#resolverObject (readonly)

Returns the value of attribute resolver.



19
20
21
# File 'lib/coradoc/reference/resolution.rb', line 19

def resolver
  @resolver
end

Instance Method Details

#call(document) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/coradoc/reference/resolution.rb', line 38

def call(document)
  results = resolve_all_edges(document)
  report_missing(results)
  return document unless materialize_policy

  materialize_tree(document, results)
end