Sha256: 7948bee06b1d0251038632280c44e84c9a0b36690db0130c2d6c127f9392c000

Contents?: true

Size: 713 Bytes

Versions: 7

Compression:

Stored size: 713 Bytes

Contents

# frozen_string_literal: true

require_relative 'base_builder'

module EasyTalk
  module Builders
    # Base builder class for array-type properties.
    class UnionBuilder
      extend T::Sig
      sig { params(name: Symbol, type: T.untyped, constraints: T.untyped).void }
      def initialize(name, type, constraints)
        @name = name
        @type = type
        @constraints = constraints
        @context = {}
      end

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

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

      def types
        @type.types
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
easy_talk-0.1.6 lib/easy_talk/builders/union_builder.rb
easy_talk-0.1.5 lib/easy_talk/builders/union_builder.rb
easy_talk-0.1.4 lib/easy_talk/builders/union_builder.rb
easy_talk-0.1.3 lib/easy_talk/builders/union_builder.rb
easy_talk-0.1.2 lib/easy_talk/builders/union_builder.rb
easy_talk-0.1.1 lib/easy_talk/builders/union_builder.rb
easy_talk-0.1.0 lib/easy_talk/builders/union_builder.rb