Module: JSON::SchemaBuilder

Extended by:
ActiveSupport::Concern, Configuration
Includes:
DSL
Defined in:
lib/json/schema_builder.rb,
lib/json/schema_builder/any.rb,
lib/json/schema_builder/dsl.rb,
lib/json/schema_builder/null.rb,
lib/json/schema_builder/array.rb,
lib/json/schema_builder/entity.rb,
lib/json/schema_builder/number.rb,
lib/json/schema_builder/object.rb,
lib/json/schema_builder/schema.rb,
lib/json/schema_builder/string.rb,
lib/json/schema_builder/boolean.rb,
lib/json/schema_builder/helpers.rb,
lib/json/schema_builder/integer.rb,
lib/json/schema_builder/numeric.rb,
lib/json/schema_builder/version.rb,
lib/json/schema_builder/attribute.rb,
lib/json/schema_builder/validation.rb,
lib/json/schema_builder/configuration.rb,
lib/json/schema_builder/rspec_helper/rspec_helper.rb,
lib/json/schema_builder/rspec_helper/deep_open_struct.rb

Defined Under Namespace

Modules: Attribute, ClassMethods, Configuration, DSL, Helpers, RSpecHelper, Validation Classes: Any, Array, Boolean, Entity, Integer, Null, Number, Numeric, Object, Schema, String

Constant Summary collapse

VERSION =
'0.8.2'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Configuration

configure, options, options=

Methods included from DSL

#entity

Class Method Details

.default_optionsObject



25
26
27
# File 'lib/json/schema_builder.rb', line 25

def self.default_options
  @options || { }
end

Instance Method Details

#initialize(context = { }) ⇒ Object



29
30
31
32
33
# File 'lib/json/schema_builder.rb', line 29

def initialize(context = { })
  context.each_pair do |key, value|
    instance_variable_set "@#{ key }", value
  end
end

#root(key = nil, &block) ⇒ Object



35
36
37
38
39
40
# File 'lib/json/schema_builder.rb', line 35

def root(key = nil, &block)
  root_key = key || self.class.root_key.to_sym
  object do
    object root_key, required: true, &block
  end
end