Class: JSONSchemer::Draft202012::Vocab::Core::UnknownKeyword

Inherits:
Keyword
  • Object
show all
Defined in:
lib/json_schemer/draft202012/vocab/core.rb

Constant Summary

Constants included from Output

Output::FRAGMENT_ENCODE_REGEX

Instance Attribute Summary

Attributes inherited from Keyword

#parent, #parsed, #root, #value

Attributes included from Output

#keyword, #schema

Instance Method Summary collapse

Methods inherited from Keyword

#absolute_keyword_location, #error_key, #initialize, #schema_pointer

Methods included from Output

#x_error

Constructor Details

This class inherits a constructor from JSONSchemer::Keyword

Instance Method Details

#fetch(token) ⇒ Object



139
140
141
142
143
144
145
146
147
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 139

def fetch(token)
  if value.is_a?(Hash)
    parsed[token] ||= JSONSchemer::Schema::UNKNOWN_KEYWORD_CLASS.new(value.fetch(token), self, token, schema)
  elsif value.is_a?(Array)
    parsed[token.to_i] ||= JSONSchemer::Schema::UNKNOWN_KEYWORD_CLASS.new(value.fetch(token.to_i), self, token, schema)
  else
    raise KeyError.new(:receiver => parsed, :key => token)
  end
end

#parseObject



129
130
131
132
133
134
135
136
137
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 129

def parse
  if value.is_a?(Hash)
    {}
  elsif value.is_a?(Array)
    []
  else
    value
  end
end

#parsed_schemaObject



149
150
151
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 149

def parsed_schema
  @parsed_schema ||= subschema(value)
end

#validate(instance, instance_location, keyword_location, _context) ⇒ Object



153
154
155
# File 'lib/json_schemer/draft202012/vocab/core.rb', line 153

def validate(instance, instance_location, keyword_location, _context)
  result(instance, instance_location, keyword_location, true, :annotation => value)
end