Class: MCPClient::SchemaValidator::Evaluated
- Inherits:
-
Object
- Object
- MCPClient::SchemaValidator::Evaluated
- Defined in:
- lib/mcp_client/schema_validator/annotations.rb
Overview
What the schemas applied to one instance value evaluated of it: the
annotation results unevaluatedProperties and unevaluatedItems read
(JSON Schema 2020-12 Core Sections 11.2 and 11.3). One is kept per
application of a schema to an object or an array, filled in by the
keywords the node evaluates itself (properties, patternProperties,
additionalProperties, prefixItems, items, contains and the two
keywords themselves) and merged from every in-place applicator whose
subschema passed — a failed subschema annotates nothing, and a cousin
(a sibling branch of the same composition) never sees it.
Instance Method Summary collapse
-
#all! ⇒ void
Every member or item is evaluated (an
itemsschema, anadditionalPropertiesschema, or the unevaluated keyword itself). -
#all? ⇒ Boolean
Whether every member or item was evaluated.
- #index!(index) ⇒ void
-
#initialize ⇒ Evaluated
constructor
A new instance of Evaluated.
-
#item?(index) ⇒ Boolean
Whether the item was evaluated.
-
#merge!(other) ⇒ Evaluated
Take over what a passed subschema evaluated of the same value.
- #name!(name) ⇒ void
- #prefix!(count) ⇒ void
-
#property?(name) ⇒ Boolean
Whether the member was evaluated.
Constructor Details
#initialize ⇒ Evaluated
Returns a new instance of Evaluated.
15 16 17 18 19 20 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 15 def initialize @all = false @names = {} @prefix = 0 @indices = {} end |
Instance Method Details
#all! ⇒ void
This method returns an undefined value.
Every member or item is evaluated (an items schema, an
additionalProperties schema, or the unevaluated keyword itself).
30 31 32 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 30 def all! @all = true end |
#all? ⇒ Boolean
Returns whether every member or item was evaluated.
23 24 25 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 23 def all? @all end |
#index!(index) ⇒ void
This method returns an undefined value.
48 49 50 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 48 def index!(index) @indices[index] = true unless @all end |
#item?(index) ⇒ Boolean
Returns whether the item was evaluated.
60 61 62 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 60 def item?(index) @all || index < @prefix || @indices.key?(index) end |
#merge!(other) ⇒ Evaluated
Take over what a passed subschema evaluated of the same value.
67 68 69 70 71 72 73 74 75 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 67 def merge!(other) return self if other.nil? return all! || self if other.all? @names.merge!(other.names) @prefix = other.prefix if other.prefix > @prefix @indices.merge!(other.indices) self end |
#name!(name) ⇒ void
This method returns an undefined value.
36 37 38 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 36 def name!(name) @names[name.to_s] = true unless @all end |
#prefix!(count) ⇒ void
This method returns an undefined value.
42 43 44 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 42 def prefix!(count) @prefix = count if count > @prefix end |
#property?(name) ⇒ Boolean
Returns whether the member was evaluated.
54 55 56 |
# File 'lib/mcp_client/schema_validator/annotations.rb', line 54 def property?(name) @all || @names.key?(name.to_s) end |