Method: JSI::SchemaModule#new_jsi

Defined in:
lib/jsi/schema_classes.rb

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

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

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::MetaSchema#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.

  • to_immutable (#call, nil)

    A proc/callable which takes given instance content and results in an immutable (i.e. deeply frozen) object equal to that. If the instantiated JSI will be mutable, this is not used. Though not recommended, this may be nil with immutable JSIs if the instance content is otherwise guaranteed to be immutable, as well as any modified copies of the instance.

  • mutable (Boolean)

    Whether the instantiated JSI will be mutable. The instance content will be transformed with to_immutable if the JSI will be immutable.

Returns:

  • (JSI::Base subclass)

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



51
52
53
# File 'lib/jsi/schema_classes.rb', line 51

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