Class: JSI::NotASchemaModule
- Inherits:
-
Object
- Object
- JSI::NotASchemaModule
- Includes:
- SchemaModulePossibly
- Defined in:
- lib/jsi/schema_classes.rb
Overview
a JSI Schema Module is a module which represents a schema. a NotASchemaModule 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 NotASchemaModule is extended with the module_for_schema of the node's schema.
NotASchemaModule holds a node which is not a schema. when subscripted, it subscripts its node. if the value is a JSI::Schema, its schema module is returned. if the value is another node, a NotASchemaModule for that node is returned. otherwise - when the value is a basic type - that value itself is returned.
Instance Attribute Summary
Attributes included from SchemaModulePossibly
Instance Method Summary collapse
-
#initialize(node) ⇒ NotASchemaModule
constructor
A new instance of NotASchemaModule.
- #inspect ⇒ String
Methods included from SchemaModulePossibly
Constructor Details
#initialize(node) ⇒ NotASchemaModule
Returns a new instance of NotASchemaModule.
249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/jsi/schema_classes.rb', line 249 def initialize(node) unless node.is_a?(JSI::PathedNode) raise(TypeError, "not JSI::PathedNode: #{node.pretty_inspect.chomp}") end if node.is_a?(JSI::Schema) raise(TypeError, "cannot instantiate NotASchemaModule for a JSI::Schema node: #{node.pretty_inspect.chomp}") end @possibly_schema_node = node node.jsi_schemas.each do |schema| extend(JSI::SchemaClasses.accessor_module_for_schema(schema, conflicting_modules: [NotASchemaModule, SchemaModulePossibly], setters: false)) end end |
Instance Method Details
#inspect ⇒ String
265 266 267 268 269 270 271 |
# File 'lib/jsi/schema_classes.rb', line 265 def inspect if name_from_ancestor "#{name_from_ancestor} (JSI wrapper for Schema Module)" else "(JSI wrapper for Schema Module: #{@possibly_schema_node.jsi_ptr.uri})" end end |