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 metaschema. 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.
Instance Attribute Summary collapse
-
#jsi_document ⇒ Object
readonly
private
document containing the schema content.
-
#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 (also: #to_s) private
- #jsi_fingerprint ⇒ Object private
- #jsi_node_content ⇒ 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.
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_describes_schema, ensure_schema, #inplace_applicator_schemas, #instance_valid?, #instance_validate, #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.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 35 def initialize( jsi_document, jsi_ptr: Ptr[], jsi_schema_base_uri: nil ) raise(Bug, "no #schema_implementation_modules") unless respond_to?(:schema_implementation_modules) super() 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 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
51 52 53 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 51 def jsi_document @jsi_document 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
54 55 56 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 54 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.
22 23 24 25 26 27 28 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 22 def inspect if self == MetaschemaNode::BootstrapSchema name 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.
30 31 32 33 34 35 36 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 30 def inspect if self == MetaschemaNode::BootstrapSchema name else -"#{name || MetaschemaNode::BootstrapSchema.name} (#{schema_implementation_modules.map(&:inspect).join(', ')})" end end |
Instance Method Details
#inspect ⇒ String Also known as: to_s
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.
83 84 85 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 83 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.
116 117 118 119 120 121 122 123 124 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 116 def jsi_fingerprint { class: self.class, jsi_ptr: @jsi_ptr, jsi_document: @jsi_document, jsi_schema_base_uri: jsi_schema_base_uri, schema_implementation_modules: schema_implementation_modules, } end |
#jsi_node_content ⇒ 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.
56 57 58 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 56 def jsi_node_content jsi_ptr.evaluate(jsi_document) 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
91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 91 def pretty_print(q) q.text '#<' q.text jsi_object_group_text.join(' ') q.group_sub { q.nest(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
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 70 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
61 62 63 64 65 66 67 |
# File 'lib/jsi/metaschema_node/bootstrap_schema.rb', line 61 def subschema(subptr) self.class.new( jsi_document, jsi_ptr: jsi_ptr + subptr, jsi_schema_base_uri: jsi_resource_ancestor_uri, ) end |