Class: JSONSkooma::Keywords::Core::Id

Inherits:
Base
  • Object
show all
Defined in:
lib/json_skooma/keywords/core/id.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) ⇒ Id

Returns a new instance of Id.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/json_skooma/keywords/core/id.rb', line 10

def initialize(parent_schema, value)
  super

  uri = URI.parse(value)
  if uri.relative?
    base_uri = parent_schema.base_uri
    if base_uri
      uri = base_uri + uri
    else
      raise "No base URI against which to resolve the `$id` value `#{value}`"
    end
  end

  parent_schema.uri = uri
end