Module: NxtSchema::Dsl

Included in:
NxtSchema
Defined in:
lib/nxt_schema/dsl.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{ type_system: NxtSchema::Types }.freeze

Instance Method Summary collapse

Instance Method Details

#any_of(name = :roots, **options, &block) ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/nxt_schema/dsl.rb', line 27

def any_of(name = :roots, **options, &block)
  NxtSchema::Template::AnyOf.new(
    name: name,
    parent_node: nil,
    **DEFAULT_OPTIONS.merge(options),
    &block
  )
end

#collection(name = :root, type: NxtSchema::Template::Collection::DEFAULT_TYPE, **options, &block) ⇒ Object Also known as: nodes



5
6
7
8
9
10
11
12
13
# File 'lib/nxt_schema/dsl.rb', line 5

def collection(name = :root, type: NxtSchema::Template::Collection::DEFAULT_TYPE, **options, &block)
  NxtSchema::Template::Collection.new(
    name: name,
    type: type,
    parent_node: nil,
    **DEFAULT_OPTIONS.merge(options),
    &block
  )
end

#params(name = :params, type: NxtSchema::Template::Schema::DEFAULT_TYPE, **options, &block) ⇒ Object

schema root with NxtSchema::Types::Params type system



38
39
40
41
42
43
44
45
46
# File 'lib/nxt_schema/dsl.rb', line 38

def params(name = :params, type: NxtSchema::Template::Schema::DEFAULT_TYPE, **options, &block)
  NxtSchema::Template::Schema.new(
    name: name,
    type: type,
    parent_node: nil,
    **options.merge(type_system: NxtSchema::Types::Params),
    &block
  )
end

#schema(name = :roots, type: NxtSchema::Template::Schema::DEFAULT_TYPE, **options, &block) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'lib/nxt_schema/dsl.rb', line 17

def schema(name = :roots, type: NxtSchema::Template::Schema::DEFAULT_TYPE, **options, &block)
  NxtSchema::Template::Schema.new(
    name: name,
    type: type,
    parent_node: nil,
    **DEFAULT_OPTIONS.merge(options),
    &block
  )
end