Module: JSI::Schema::SchemaAncestorNode

Included in:
Base
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 Method Summary collapse

Instance Method Details

#jsi_anchor_subschema(anchor) ⇒ JSI::Schema?

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

Returns:


38
39
40
41
42
43
44
45
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 38

def jsi_anchor_subschema(anchor)
  subschemas = jsi_anchor_subschemas_map[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:


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

def jsi_anchor_subschemas(anchor)
  jsi_anchor_subschemas_map[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
30
31
32
33
# File 'lib/jsi/schema/schema_ancestor_node.rb', line 27

def jsi_resource_ancestor_uri
  if is_a?(Schema) && schema_absolute_uri
    schema_absolute_uri
  else
    jsi_schema_base_uri
  end
end