Sha256: d8991050b8d49c6a6bc35f5f46a0b8586db971498dd8f1bf4345be447274c629

Contents?: true

Size: 454 Bytes

Versions: 24

Compression:

Stored size: 454 Bytes

Contents

# frozen_string_literal: true

module Cocina
  module Generator
    # Class for generating a union type
    class UnionType < SchemaBase
      def generate
        <<~RUBY
          # frozen_string_literal: true

          module Cocina
            module Models
              #{name} = #{type_names}
            end
          end
        RUBY
      end

      def type_names
        schema_doc.one_of.map(&:name).join(' | ')
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
cocina-models-0.89.0 lib/cocina/generator/union_type.rb
cocina-models-0.88.0 lib/cocina/generator/union_type.rb
cocina-models-0.87.1 lib/cocina/generator/union_type.rb
cocina-models-0.87.0 lib/cocina/generator/union_type.rb