Module: JSI::Schema::SchemaAncestorNode

Included in:
Base, MetaSchemaNode::BootstrapSchema
Defined in:
lib/jsi/schema/schema_ancestor_node.rb

Overview

a node in a document which may contain a schema somewhere within is extended with SchemaAncestorNode, for tracking things necessary for a schema to function correctly

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#jsi_base_uriURI?

Base URI for URI resolution - always an absolute URI (with no fragment). If this node is a resource, its #jsi_resource_uri (i.e. its $id) is resolved against this URI, if that is relative.

At the root this comes from param base_uri of new_jsi/new_schema, or from a configured root_uri. Below the root this comes from the parent's #jsi_next_base_uri.

Returns:

  • (URI, nil)


26
27
28
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 26

def jsi_base_uri
  @jsi_base_uri
end

#jsi_schema_dynamic_anchor_mapSchema::DynamicAnchorMap

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.



40
41
42
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 40

def jsi_schema_dynamic_anchor_map
  @jsi_schema_dynamic_anchor_map
end

#jsi_schema_resource_ancestorsArray<JSI::Schema>

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.

resources which are ancestors of this JSI in the document. this does not include self.

Returns:



36
37
38
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 36

def jsi_schema_resource_ancestors
  @jsi_schema_resource_ancestors
end

Instance Method Details

#initializeObject



8
9
10
11
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 8

def initialize(*)
  super
  jsi_schema_ancestor_node_initialize
end

#jsi_anchor_subschemas(anchor) ⇒ Set<JSI::Schema>

All schemas at or below this node with the given anchor.

Returns:



112
113
114
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 112

def jsi_anchor_subschemas(anchor)
  @anchor_subschemas_map[anchor: anchor, content: jsi_node_content]
end

#jsi_is_resource_root?Boolean

Returns:

  • (Boolean)


55
56
57
58
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 55

def jsi_is_resource_root?
  # overridden by Schema
  jsi_ptr.root?
end

#jsi_next_base_uriURI?

URI for resolution of relative URIs at or below this node - always an absolute URI (with no fragment). Mainly used to resolve relative $refs. This is self's #jsi_resource_uri if this node is a resource; otherwise #jsi_base_uri.

Returns:

  • (URI, nil)


82
83
84
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 82

def jsi_next_base_uri
  jsi_resource_uri || jsi_base_uri
end

#jsi_resource_rootSchema::SchemaAncestorNode?

Returns:



49
50
51
52
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 49

def jsi_resource_root
  # overridden by Base. may be nil from MetaSchemaNode::BootstrapSchema.
  jsi_is_resource_root? ? self : jsi_schema_resource_ancestors.last
end

#jsi_resource_uriURI?

An absolute URI identifying this node, if this node is a resource root. Typically from a schema's $id keyword.

Returns:

  • (URI, nil)


63
64
65
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 63

def jsi_resource_uri
  jsi_resource_uris.first
end

#jsi_resource_urisEnumerable<URI>

Absolute URIs identifying this node - typically one URI if this is a resource root, otherwise none.

Returns:

  • (Enumerable<URI>)


69
70
71
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 69

def jsi_resource_uris
  @resource_uris_map[content: jsi_node_content]
end

#jsi_schema_base_uriObject

Deprecated.

after v0.8



29
30
31
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 29

def jsi_schema_base_uri
  jsi_base_uri
end

#jsi_schema_registryObject

Deprecated.

after v0.8



43
44
45
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 43

def jsi_schema_registry
  jsi_registry
end