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.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, type, constraints) ⇒ UnionBuilder

Returns a new instance of UnionBuilder.



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

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

Class Method Details

.collection_type?Boolean Originally defined in module CollectionHelpers

Returns:

  • (Boolean)

Instance Method Details

#buildObject



22
23
24
25
26
# File 'lib/easy_talk/builders/union_builder.rb', line 22

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

#schemasObject



29
30
31
32
33
# File 'lib/easy_talk/builders/union_builder.rb', line 29

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

#typesObject



36
37
38
# File 'lib/easy_talk/builders/union_builder.rb', line 36

def types
  @type.types
end