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 a parent schema or the URI from which the document was retrieved.

Returns:

  • (Addressable::URI, nil)


12
13
14
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 12

def jsi_schema_base_uri
  @jsi_schema_base_uri
end

Instance Method Details

#jsi_anchor_subschema(anchor) ⇒ JSI::Schema?

a schema at or below this node with the given anchor.

Returns:



34
35
36
37
38
39
40
41
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 34

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

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

schemas at or below node with the given anchor.

Returns:



46
47
48
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 46

def jsi_anchor_subschemas(anchor)
  jsi_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 a parent resource's URI, or nil if not contained by a resource with a URI.

Returns:

  • (Addressable::URI, nil)


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

def jsi_resource_ancestor_uri
  (is_a?(Schema) && schema_absolute_uri) || jsi_schema_base_uri
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:



17
18
19
20
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 17

def jsi_schema_resource_ancestors
  return @jsi_schema_resource_ancestors if instance_variable_defined?(:@jsi_schema_resource_ancestors)
  Util::EMPTY_ARY
end