Class: JSI::Base::Conf
- Inherits:
-
Object
- Object
- JSI::Base::Conf
- Defined in:
- lib/jsi/base.rb
Overview
Configuration, shared across all nodes of a document. A JSI's #jsi_conf.
Configuration parameters are set from **conf_kw params passed to #new_jsi,
#new_schema and related methods.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#after_initialize ⇒ #call?
EXPERIMENTAL - a callback that is called with each JSI node in the document after the node is initialized.
-
#application_collect_evaluated_validate ⇒ Boolean
Shall schema application perform validation when collecting child evaluation (for
unevaluatedProperties,unevaluatedItems)?. -
#child_as_jsi ⇒ Boolean
Default value for #jsi_as_child_default_as_jsi.
-
#child_use_default ⇒ Boolean
Default value for #jsi_child_use_default_default.
-
#registry ⇒ Registry?
The registry from which references are resolved.
-
#reinstantiate_nonschemas ⇒ Object
private, not officially supported.
-
#root_uri ⇒ URI?
A URI identifying the document root resource.
-
#to_immutable ⇒ #call?
A callable that transforms given instance content to an immutable (i.e. deeply frozen) object equal to it.
Instance Method Summary collapse
-
#initialize(root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw) ⇒ Conf
constructor
A new instance of Conf.
Constructor Details
#initialize(root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw) ⇒ Conf
Returns a new instance of Conf.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/jsi/base.rb', line 118 def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end |
Instance Attribute Details
#after_initialize ⇒ #call?
EXPERIMENTAL - a callback that is called with each JSI node in the document after the node is initialized.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |
#application_collect_evaluated_validate ⇒ Boolean
Shall schema application perform validation when collecting child evaluation
(for unevaluatedProperties, unevaluatedItems)?
A child should not be considered evaluated by a schema when it fails to validate[^1].
This means that unevaluatedItems or unevaluatedProperties should
only apply to a child if no other applicator schema validates the child.
The computational cost of this validation is significant, however, and may be unacceptable for performance.
Set to true, child evaluation will perform validation, and unevaluated* will applicate
correctly, at some cost in CPU time.
Set to false, a child will be considered evaluated when a child applicator schema applies to it,
regardless of validity, which will result in an unevaluated* schema incorrectly failing to
applicate when the child is not valid.
The default is false. It is expected that application of unevaluated* schemas to such children
is not typically relied on, so validation is not typically worth the cost of its computation.
[^1]: (ref: the JSON Schema spec states, "Schema objects that produce a false assertion result MUST NOT produce any annotation results, whether from their own keywords or from keywords in subschemas.")
Default: false
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |
#child_as_jsi ⇒ Boolean
Default value for JSI::Base#jsi_as_child_default_as_jsi.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |
#child_use_default ⇒ Boolean
Default value for JSI::Base#jsi_child_use_default_default.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |
#registry ⇒ Registry?
The registry from which references are resolved.
For schemas (or documents containing schemas), this is mainly used with $ref values.
It is unused in instances that do not contain schemas.
Default: JSI.registry
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |
#reinstantiate_nonschemas ⇒ Object
private, not officially supported. whether Schema#resource_root_subschema reinstantiates.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |
#root_uri ⇒ URI?
A URI identifying the document root resource.
References (e.g. a schema $ref) can resolve the resource with this URI.
It is rare that this needs to be specified. Most resources that would be
referenced are schemas that use the $id keyword to specify their URI.
However, there are cases when a resource may be referenced using a retrieval URI
that does not match the resource's $id, and root_uri enables resolution.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |
#to_immutable ⇒ #call?
A callable that transforms given instance content to an immutable (i.e. deeply frozen) object equal to it.
Used when instantiating immutable JSIs and modified copies of them, so their content is immutable.
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.
Default: DEFAULT_CONTENT_TO_IMMUTABLE
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/jsi/base.rb', line 117 class Conf def initialize( root_uri: nil, registry: JSI.registry, application_collect_evaluated_validate: false, child_as_jsi: false, child_use_default: false, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, **kw ) super( root_uri: Util.uri(root_uri, nnil: false, yabs: true), registry: registry, application_collect_evaluated_validate: application_collect_evaluated_validate, child_as_jsi: child_as_jsi, child_use_default: child_use_default, to_immutable: to_immutable, **kw, ) freeze end # @private # @return [Hash] def for_fingerprint to_h.select { |k, _| self.class::ATTRS.fetch(k).fetch(:fingerprint) }.freeze end end |