Module: JSI::SchemaClasses Private

Defined in:
lib/jsi/schema_classes.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

this module is a namespace for building schema classes and schema modules.

Class Method Summary collapse

Class Method Details

.bootstrap_schema_class(modules) ⇒ Class

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.

a subclass of MetaSchemaNode::BootstrapSchema with the given modules included

Parameters:

  • modules (Set<Module>)

    schema implementation modules

Returns:

  • (Class)


164
165
166
167
168
# File 'lib/jsi/schema_classes.rb', line 164

def bootstrap_schema_class(modules)
  @bootstrap_schema_class_map[
    modules: Util.ensure_module_set(modules),
  ]
end

.class_for_schemas(schemas, includes:, mutable:) ⇒ Class subclassing JSI::Base

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.

a JSI Schema Class which represents the given schemas. an instance of the class is a JSON Schema instance described by all of the given schemas.

Parameters:

  • schemas (Enumerable<JSI::Schema>)

    schemas which the class will represent

  • includes (Enumerable<Module>)

    modules which will be included on the class

Returns:



116
117
118
119
120
121
122
# File 'lib/jsi/schema_classes.rb', line 116

def class_for_schemas(schemas, includes: , mutable: )
  @class_for_schemas_map[
    schemas: SchemaSet.ensure_schema_set(schemas),
    includes: Util.ensure_module_set(includes),
    mutable: mutable,
  ]
end

.module_for_schema(schema) ⇒ SchemaModule

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.

see JSI::Schema#jsi_schema_module

Returns:

Raises:



183
184
185
186
187
# File 'lib/jsi/schema_classes.rb', line 183

def module_for_schema(schema)
  Schema.ensure_schema(schema)
  raise(Bug, "non-Base schema cannot have schema module: #{schema}") unless schema.is_a?(Base)
  @schema_module_map[schema]
end