Module: Servus::Schema::Path Private
- Defined in:
- lib/servus/schema/path.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Walks a path of literal keys into a registered schema fragment.
This is the single addressing implementation behind both
fetch and $ref resolution, so a path that misses reads
the same whether application code asked for it directly or a ref led there.
Segments are literal hash keys, not JSON Pointer tokens — there is no +~0+/+~1+ unescaping and no array indexing.
Class Method Summary collapse
-
.walk(fragment, key, path) ⇒ Object
private
Walks
pathintofragment.
Class Method Details
.walk(fragment, key, path) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Walks path into fragment.
26 27 28 29 30 31 32 33 34 |
# File 'lib/servus/schema/path.rb', line 26 def walk(fragment, key, path) path.reduce(fragment) do |current, segment| unless current.is_a?(Hash) && current.key?(segment) raise RefNotFoundError, (key, path, segment, current) end current[segment] end end |