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.99.1 lib/cocina/generator/union_type.rb
cocina-models-0.99.0 lib/cocina/generator/union_type.rb
cocina-models-0.98.1 lib/cocina/generator/union_type.rb
cocina-models-0.98.0 lib/cocina/generator/union_type.rb
cocina-models-0.96.0 lib/cocina/generator/union_type.rb
cocina-models-0.95.1 lib/cocina/generator/union_type.rb
cocina-models-0.95.0 lib/cocina/generator/union_type.rb
cocina-models-0.94.2 lib/cocina/generator/union_type.rb
cocina-models-0.94.1 lib/cocina/generator/union_type.rb
cocina-models-0.94.0 lib/cocina/generator/union_type.rb
cocina-models-0.93.1 lib/cocina/generator/union_type.rb
cocina-models-0.93.0 lib/cocina/generator/union_type.rb
cocina-models-0.92.0 lib/cocina/generator/union_type.rb
cocina-models-0.91.4 lib/cocina/generator/union_type.rb
cocina-models-0.91.3 lib/cocina/generator/union_type.rb
cocina-models-0.91.2 lib/cocina/generator/union_type.rb
cocina-models-0.91.1 lib/cocina/generator/union_type.rb
cocina-models-0.91.0 lib/cocina/generator/union_type.rb
cocina-models-0.90.0 lib/cocina/generator/union_type.rb
cocina-models-0.89.1 lib/cocina/generator/union_type.rb