Class: JSONSkooma::Keywords::Core::DynamicAnchor

Inherits:
Base
  • Object
show all
Defined in:
lib/json_skooma/keywords/core/dynamic_anchor.rb

Instance Attribute Summary

Attributes inherited from Base

#json, #parent_schema

Instance Method Summary collapse

Methods inherited from Base

#each_schema, #evaluate, inherited, #instance_types, #key, #resolve, set_defaults, #static, value_schema=

Constructor Details

#initialize(parent_schema, value) ⇒ DynamicAnchor

Returns a new instance of DynamicAnchor.

Raises:



10
11
12
13
14
15
16
17
18
# File 'lib/json_skooma/keywords/core/dynamic_anchor.rb', line 10

def initialize(parent_schema, value)
  super

  base_uri = parent_schema.base_uri
  raise Error, "No base URI for `$dynamicAnchor` value `#{value}`" if base_uri.nil?

  uri = base_uri.dup.tap { |u| u.fragment = value }
  parent_schema.registry.add_schema(uri, parent_schema, cache_id: parent_schema.cache_id)
end