Class: JSI::SchemaModule

Inherits:
Module
  • Object
show all
Includes:
Connects
Defined in:
lib/jsi/schema_classes.rb,
lib/jsi/schema_classes.rb

Overview

A Module associated with a JSI Schema. See JSI::Schema#jsi_schema_module.

Defined Under Namespace

Modules: Connects, DescribesSchemaModule Classes: Connection

Instance Attribute Summary

Attributes included from Connects

#jsi_node

Instance Method Summary collapse

Methods included from Connects

#[], #name_from_ancestor

Instance Method Details

#inspectString Also known as: to_s

Returns:

  • (String)


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/jsi/schema_classes.rb', line 30

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

#instance_valid?(instance) ⇒ Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/jsi/schema_classes.rb', line 64

def instance_valid?(instance)
  schema.instance_valid?(instance)
end

#instance_validate(instance) ⇒ Object



59
60
61
# File 'lib/jsi/schema_classes.rb', line 59

def instance_validate(instance)
  schema.instance_validate(instance)
end

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

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

Parameters:

  • instance (Object)

    the instance to be represented as a JSI

  • uri (#to_str, Addressable::URI)

    The retrieval URI of the instance.

    It is rare that this needs to be specified, and only useful for instances which contain schemas. See JSI::Schema::DescribesSchema#new_schema's uri param documentation.

  • register (Boolean)

    Whether schema resources in the instantiated JSI will be registered in the schema registry indicated by param schema_registry. This is only useful when the JSI is a schema or contains schemas. The JSI's root will be registered with the uri param, if specified, whether or not the root is a schema.

  • schema_registry (SchemaRegistry, nil)

    The registry to use for references to other schemas and, depending on register and uri params, to register this JSI and/or any contained schemas with declared URIs.

  • stringify_symbol_keys (Boolean)

    Whether the instance content will have any Symbol keys of Hashes replaced with Strings (recursively through the document). Replacement is done on a copy; the given instance is not modified.

Returns:

  • (JSI::Base subclass)

    a JSI whose content comes from the given instance and whose schemas are inplace applicators of this module's schema.



49
50
51
# File 'lib/jsi/schema_classes.rb', line 49

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

#schemaBase + Schema

The schema for which this is the JSI Schema Module

Returns:



19
20
21
# File 'lib/jsi/schema_classes.rb', line 19

def schema
  @jsi_node
end

#schema_contentObject



54
55
56
# File 'lib/jsi/schema_classes.rb', line 54

def schema_content
  schema.jsi_node_content
end

#schema_uriAddressable::URI?

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

Returns:

  • (Addressable::URI, nil)


25
26
27
# File 'lib/jsi/schema_classes.rb', line 25

def schema_uri
  schema.schema_uri
end