Class: JSI::SchemaModule::Connection

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

Overview

A JSI Schema Module is a module which represents a schema. A SchemaModule::Connection represents a node in a schema's document which is not a schema, such as the 'properties' object (which contains schemas but is not a schema).

instances of this class act as a stand-in to allow users to subscript or call property accessors on schema modules to refer to their subschemas' schema modules.

A SchemaModule::Connection has readers for property names described by the node's schemas.

Instance Attribute Summary

Attributes included from Connects

#jsi_node

Instance Method Summary collapse

Methods included from Connects

#[], #name_from_ancestor

Constructor Details

#initialize(node) ⇒ Connection

Returns a new instance of Connection.

Parameters:

Raises:



337
338
339
340
341
342
343
344
# File 'lib/jsi/schema_classes.rb', line 337

def initialize(node)
  raise(Bug, "node must be JSI::Base: #{node.pretty_inspect.chomp}") unless node.is_a?(JSI::Base)
  raise(Bug, "node must not be JSI::Schema: #{node.pretty_inspect.chomp}") if node.is_a?(JSI::Schema)
  @jsi_node = node
  node.jsi_schemas.each do |schema|
    extend(JSI::SchemaClasses.schema_property_reader_module(schema, conflicting_modules: [SchemaModule::Connection]))
  end
end

Instance Method Details

#inspectString Also known as: to_s

Returns:

  • (String)


347
348
349
350
351
352
353
# File 'lib/jsi/schema_classes.rb', line 347

def inspect
  if name_from_ancestor
    -"#{name_from_ancestor} (#{self.class})"
  else
    -"(#{self.class}: #{@jsi_node.jsi_ptr.uri})"
  end
end