Class: Schemify::Schema

Inherits:
Object
  • Object
show all
Includes:
Vocabularies::Applicator::KeywordMethods, Vocabularies::Content::KeywordMethods, Vocabularies::Core::KeywordMethods, Vocabularies::FormatAnnotation::KeywordMethods, Vocabularies::MetaData::KeywordMethods, Vocabularies::Unevaluated::KeywordMethods, Vocabularies::Validation::KeywordMethods
Defined in:
lib/schemify/schema.rb

Overview

A JSON Schema representation

Instance Method Summary collapse

Constructor Details

#initializeSchema

Returns a new instance of Schema.



16
17
18
19
# File 'lib/schemify/schema.rb', line 16

def initialize(&)
  @keywords = {}
  instance_eval(&) if block_given?
end

Instance Method Details

#to_hObject



21
22
23
24
25
26
27
# File 'lib/schemify/schema.rb', line 21

def to_h
  schema = {}
  @keywords.each_value do |keyword|
    schema.merge!(keyword.to_h)
  end
  schema
end