Class: Coradoc::Reference::Resolver::Catalog
- Inherits:
-
Resolver::Base
- Object
- Resolver::Base
- Coradoc::Reference::Resolver::Catalog
- Defined in:
- lib/coradoc/reference/resolver/catalog.rb
Overview
Asks one catalog. Applies the ambiguous: policy in-line.
Does NOT apply the missing: policy — that's the caller's
call (Resolution orchestrator) — but it does surface the
Missing Result so the caller can decide.
Instance Attribute Summary collapse
-
#ambiguous_policy ⇒ Object
readonly
Returns the value of attribute ambiguous_policy.
-
#catalog ⇒ Object
readonly
Returns the value of attribute catalog.
-
#missing_policy ⇒ Object
readonly
Returns the value of attribute missing_policy.
Instance Method Summary collapse
-
#initialize(catalog:, ambiguous: :disambiguate, missing: :warn) ⇒ Catalog
constructor
A new instance of Catalog.
- #resolve(edge) ⇒ Object
Constructor Details
#initialize(catalog:, ambiguous: :disambiguate, missing: :warn) ⇒ Catalog
Returns a new instance of Catalog.
13 14 15 16 17 18 |
# File 'lib/coradoc/reference/resolver/catalog.rb', line 13 def initialize(catalog:, ambiguous: :disambiguate, missing: :warn) super() @catalog = catalog @ambiguous_policy = ambiguous @missing_policy = missing end |
Instance Attribute Details
#ambiguous_policy ⇒ Object (readonly)
Returns the value of attribute ambiguous_policy.
11 12 13 |
# File 'lib/coradoc/reference/resolver/catalog.rb', line 11 def ambiguous_policy @ambiguous_policy end |
#catalog ⇒ Object (readonly)
Returns the value of attribute catalog.
11 12 13 |
# File 'lib/coradoc/reference/resolver/catalog.rb', line 11 def catalog @catalog end |
#missing_policy ⇒ Object (readonly)
Returns the value of attribute missing_policy.
11 12 13 |
# File 'lib/coradoc/reference/resolver/catalog.rb', line 11 def missing_policy @missing_policy end |
Instance Method Details
#resolve(edge) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/coradoc/reference/resolver/catalog.rb', line 20 def resolve(edge) address = edge.address return missing_for(edge, address) unless catalog.recognizes_scheme?(address.scheme) result = catalog.lookup(address) return missing_for(edge, address) if result.nil? return resolved_for(edge, address, result) unless result.is_a?(Array) resolve_ambiguous(edge, address, result) end |