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_schema_base_uriAddressable::URI?

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.

the base URI used to resolve the ids of schemas at or below this JSI. this is always an absolute URI (with no fragment). This may be the absolute schema URI of an ancestor schema or the URI from which the document was retrieved.

Returns:

  • (Addressable::URI, nil)


24
25
26
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 24

def jsi_schema_base_uri
  @jsi_schema_base_uri
end

#jsi_schema_registrySchemaRegistry

See JSI::SchemaSet#new_jsi param schema_registry

Returns:



33
34
35
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 33

def jsi_schema_registry
  @jsi_schema_registry
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:



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

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_subschema(anchor) ⇒ JSI::Schema?

The schema at or below this node with the given anchor. If no schema has that anchor (or multiple schemas do, incorrectly), nil.

Returns:



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

def jsi_anchor_subschema(anchor)
  subschemas = @anchor_subschemas_map[anchor: anchor]
  if subschemas.size == 1
    subschemas.first
  else
    nil
  end
end

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

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

Returns:



60
61
62
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 60

def jsi_anchor_subschemas(anchor)
  @anchor_subschemas_map[anchor: anchor]
end

#jsi_resource_ancestor_uriAddressable::URI?

the URI of the resource containing this node. this is always an absolute URI (with no fragment). If this node is a schema with an id, this is its absolute URI; otherwise an ancestor resource's URI, or nil if not contained by a resource with a URI.

Returns:

  • (Addressable::URI, nil)


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

def jsi_resource_ancestor_uri
  (is_a?(Schema) && schema_absolute_uri) || jsi_schema_base_uri
end