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 (also: #to_s)
Methods included from SchemaModulePossibly
Constructor Details
#initialize(node) ⇒ NotASchemaModule
Returns a new instance of NotASchemaModule.
276 277 278 279 280 281 282 283 |
# File 'lib/jsi/schema_classes.rb', line 276 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) @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 Also known as: to_s
288 289 290 291 292 293 294 |
# File 'lib/jsi/schema_classes.rb', line 288 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 |