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:



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

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

Returns:

  • (String)


355
356
357
358
359
360
361
# File 'lib/jsi/schema_classes.rb', line 355

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

#to_sObject



363
364
365
# File 'lib/jsi/schema_classes.rb', line 363

def to_s
  inspect
end