Module: JSI::SchemaModule

Defined in:
lib/jsi/schema_classes.rb

Overview

JSI Schema Modules are extended with JSI::SchemaModule

Instance Method Summary collapse

Instance Method Details

#inspectString Also known as: to_s

Returns:

  • (String)


19
20
21
22
23
24
25
# File 'lib/jsi/schema_classes.rb', line 19

def inspect
  if name_from_ancestor
    "#{name_from_ancestor} (JSI Schema Module)"
  else
    "(JSI Schema Module: #{schema.schema_uri || schema.jsi_ptr.uri})"
  end
end

#new_jsi(instance, **kw) ⇒ JSI::Base

invokes JSI::Schema#new_jsi on this module's schema, passing the given instance.

Parameters:

  • instance (Object)

    the JSON Schema instance to be represented as a JSI

  • uri (nil, #to_str, Addressable::URI)

    for an instance document containing schemas, this is the URI of the document, whether or not the document is itself a schema. in the normal case where the document does not contain any schemas, uri has no effect. schemas within the document use this uri as the base URI to resolve relative URIs. the resulting JSI may be registered with a JSI::SchemaRegistry (see JSI.schema_registry).

Returns:

  • (JSI::Base)

    a JSI whose instance is the given instance



33
34
35
# File 'lib/jsi/schema_classes.rb', line 33

def new_jsi(instance, **kw)
  schema.new_jsi(instance, **kw)
end

#schemaSchema

the schema of which this is the JSI Schema Module

Returns:



# File 'lib/jsi/schema_classes.rb', line 6

#schema_uriAddressable::URI?

a URI which refers to the schema. see JSI::Schema#schema_uri.

Returns:

  • (Addressable::URI, nil)


14
15
16
# File 'lib/jsi/schema_classes.rb', line 14

def schema_uri
  schema.schema_uri
end