Class: JSI::MetaSchemaNode::BootstrapSchema Private
- Inherits:
-
Object
- Object
- JSI::MetaSchemaNode::BootstrapSchema
- Includes:
- Schema, Schema::SchemaAncestorNode, Util::FingerprintHash
- Defined in:
- lib/jsi/metaschema_node/bootstrap_schema.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
internal class to bootstrap a meta-schema. represents a schema without the complexity of JSI::Base. the schema is represented but schemas describing the schema are not.
this class is to only be instantiated on nodes in the document that are known to be schemas. Schema#subschema and Schema#resource_root_subschema are the intended mechanisms to instantiate subschemas and resolve references. #[] and #jsi_root_node are not implemented.
schema implementation modules are included on generated subclasses of BootstrapSchema by SchemaClasses.bootstrap_schema_class. that subclass is instantiated with a document and pointer, representing a schema.
BootstrapSchema does not support mutation; its document must be immutable.
Instance Attribute Summary collapse
-
#jsi_document ⇒ Object
readonly
private
document containing the schema content.
- #jsi_node_content ⇒ Object readonly private
-
#jsi_ptr ⇒ Object
readonly
private
JSI::Ptr pointing to this schema within the document.
Attributes included from Schema::SchemaAncestorNode
#jsi_schema_base_uri, #jsi_schema_registry, #jsi_schema_resource_ancestors
Class Method Summary collapse
- .inspect ⇒ Object private
- .to_s ⇒ Object private
Instance Method Summary collapse
-
#initialize(jsi_document, jsi_ptr: Ptr[], jsi_schema_base_uri: nil) ⇒ BootstrapSchema
constructor
private
A new instance of BootstrapSchema.
- #inspect ⇒ String private
- #jsi_fingerprint ⇒ Object private
-
#pretty_print(q)
private
pretty-prints a representation of self to the given printer.
-
#resource_root_subschema(ptr) ⇒ Object
private
overrides Schema#resource_root_subschema.
-
#subschema(subptr) ⇒ Object
private
overrides Schema#subschema.
- #to_s ⇒ Object private
Methods included from Schema
#child_applicator_schemas, #described_object_property_names, #describes_schema!, #describes_schema?, #each_child_applicator_schema, #each_inplace_applicator_schema, #each_schema_uri, ensure_metaschema, ensure_schema, #inplace_applicator_schemas, #instance_valid?, #instance_validate, #jsi_is_schema?, #jsi_schema_module, #jsi_schema_module_exec, #jsi_subschema_resource_ancestors, #keyword?, #new_jsi, #schema_absolute_uri, #schema_content, #schema_ref, #schema_resource_root, #schema_resource_root?, #schema_uri, #schema_uris
Methods included from Schema::SchemaAncestorNode
#jsi_anchor_subschema, #jsi_anchor_subschemas, #jsi_resource_ancestor_uri
Constructor Details
#initialize(jsi_document, jsi_ptr: Ptr[], jsi_schema_base_uri: nil) ⇒ BootstrapSchema
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.
Returns a new instance of BootstrapSchema.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 39 def initialize( jsi_document, jsi_ptr: Ptr[], jsi_schema_base_uri: nil ) raise(Bug, "no #schema_implementation_modules") unless respond_to?(:schema_implementation_modules) self.jsi_ptr = jsi_ptr self.jsi_document = jsi_document self.jsi_schema_base_uri = jsi_schema_base_uri self.jsi_schema_resource_ancestors = Util::EMPTY_ARY @jsi_node_content = jsi_ptr.evaluate(jsi_document) #chkbug raise(Bug, 'BootstrapSchema instance must be frozen') unless jsi_node_content.frozen? super() end |
Instance Attribute Details
#jsi_document ⇒ Object (readonly)
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.
document containing the schema content
58 59 60 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 58 def jsi_document @jsi_document end |
#jsi_node_content ⇒ Object (readonly)
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.
63 64 65 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 63 def jsi_node_content @jsi_node_content end |
#jsi_ptr ⇒ Object (readonly)
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.
JSI::Ptr pointing to this schema within the document
61 62 63 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 61 def jsi_ptr @jsi_ptr end |
Class Method Details
.inspect ⇒ Object
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.
24 25 26 27 28 29 30 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 24 def inspect if self == MetaSchemaNode::BootstrapSchema name.freeze else -"#{name || MetaSchemaNode::BootstrapSchema.name} (#{schema_implementation_modules.map(&:inspect).join(', ')})" end end |
.to_s ⇒ Object
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.
32 33 34 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 32 def to_s inspect end |
Instance Method Details
#inspect ⇒ String
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.
88 89 90 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 88 def inspect -"\#<#{jsi_object_group_text.join(' ')} #{schema_content.inspect}>" end |
#jsi_fingerprint ⇒ Object
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.
121 122 123 124 125 126 127 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 121 def jsi_fingerprint { class: self.class, jsi_ptr: @jsi_ptr, jsi_document: @jsi_document, }.freeze end |
#pretty_print(q)
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.
This method returns an undefined value.
pretty-prints a representation of self to the given printer
98 99 100 101 102 103 104 105 106 107 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 98 def pretty_print(q) q.text '#<' q.text jsi_object_group_text.join(' ') q.group(2) { q.breakable ' ' q.pp schema_content } q.breakable '' q.text '>' end |
#resource_root_subschema(ptr) ⇒ Object
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.
overrides Schema#resource_root_subschema
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 75 def resource_root_subschema(ptr) # BootstrapSchema does not track jsi_schema_resource_ancestors used by Schema#schema_resource_root; # resource_root_subschema is always relative to the document root. # BootstrapSchema also does not implement jsi_root_node or #[]. we instantiate the ptr directly # rather than as a subschema from the root. self.class.new( jsi_document, jsi_ptr: Ptr.ary_ptr(ptr), jsi_schema_base_uri: nil, ) end |
#subschema(subptr) ⇒ Object
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.
overrides Schema#subschema
66 67 68 69 70 71 72 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 66 def subschema(subptr) self.class.new( jsi_document, jsi_ptr: jsi_ptr + subptr, jsi_schema_base_uri: jsi_resource_ancestor_uri, ) end |
#to_s ⇒ Object
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.
92 93 94 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 92 def to_s inspect end |