Class: EasyTalk::Builders::UnionBuilder

Inherits:
Object
  • Object
show all
Extended by:
CollectionHelpers, T::Sig
Defined in:
lib/easy_talk/builders/union_builder.rb

Overview

Base builder class for array-type properties.

Instance Method Summary collapse

Methods included from CollectionHelpers

collection_type?

Constructor Details

#initialize(name, type, constraints) ⇒ UnionBuilder

Returns a new instance of UnionBuilder.



13
14
15
16
17
18
# File 'lib/easy_talk/builders/union_builder.rb', line 13

def initialize(name, type, constraints)
  @name = name
  @type = type
  @constraints = constraints
  @context = {}
end

Instance Method Details

#buildObject



20
21
22
23
24
# File 'lib/easy_talk/builders/union_builder.rb', line 20

def build
  @context[@name] = {
    'anyOf' => schemas
  }
end

#schemasObject



26
27
28
29
30
# File 'lib/easy_talk/builders/union_builder.rb', line 26

def schemas
  types.map do |type|
    Property.new(@name, type, @constraints).build
  end
end

#typesObject



32
33
34
# File 'lib/easy_talk/builders/union_builder.rb', line 32

def types
  @type.types
end