Class: Glossarist::ResolutionAdapter::Route
- Inherits:
-
Glossarist::ResolutionAdapter
- Object
- Glossarist::ResolutionAdapter
- Glossarist::ResolutionAdapter::Route
- Defined in:
- lib/glossarist/resolution_adapter/route.rb
Instance Attribute Summary collapse
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
Instance Method Summary collapse
- #add(from:, to:) ⇒ Object
-
#initialize(routes = {}) ⇒ Route
constructor
A new instance of Route.
- #remap(source) ⇒ Object
- #resolve(reference) ⇒ Object
Constructor Details
#initialize(routes = {}) ⇒ Route
Returns a new instance of Route.
8 9 10 11 |
# File 'lib/glossarist/resolution_adapter/route.rb', line 8 def initialize(routes = {}) super() @routes = routes end |
Instance Attribute Details
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
6 7 8 |
# File 'lib/glossarist/resolution_adapter/route.rb', line 6 def routes @routes end |
Instance Method Details
#add(from:, to:) ⇒ Object
13 14 15 |
# File 'lib/glossarist/resolution_adapter/route.rb', line 13 def add(from:, to:) @routes[from] = to end |
#remap(source) ⇒ Object
29 30 31 |
# File 'lib/glossarist/resolution_adapter/route.rb', line 29 def remap(source) routes[source] || source end |
#resolve(reference) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/glossarist/resolution_adapter/route.rb', line 17 def resolve(reference) return nil unless reference.ref_type == "urn" return nil unless routes.key?(reference.source) ConceptReference.new( term: reference.term, concept_id: reference.concept_id, source: routes[reference.source], ref_type: reference.ref_type, ) end |