Sha256: 3a30e393ac610b9f6b00bdc085976914b28d1f4d33c0bf776189e0ed42c880e0

Contents?: true

Size: 550 Bytes

Versions: 40

Compression:

Stored size: 550 Bytes

Contents

# frozen_string_literal: true

module Cocina
  module Generator
    # Class for generating from an openapi array
    class SchemaArray < SchemaBase
      def generate
        "attribute :#{name.camelize(:lower)}, Types::Strict::Array.of(#{array_of_type})#{omittable}"
      end

      def omittable
        if required
          '.default([].freeze)'
        else
          '.meta(omittable: true)'
        end
      end

      def array_of_type
        schema_doc.items.name || "Types::#{dry_datatype(schema_doc.items)}"
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
cocina-models-0.58.2 lib/cocina/generator/schema_array.rb
cocina-models-0.58.1 lib/cocina/generator/schema_array.rb
cocina-models-0.58.0 lib/cocina/generator/schema_array.rb
cocina-models-0.57.0 lib/cocina/generator/schema_array.rb
cocina-models-0.56.1 lib/cocina/generator/schema_array.rb
cocina-models-0.56.0 lib/cocina/generator/schema_array.rb
cocina-models-0.55.0 lib/cocina/generator/schema_array.rb
cocina-models-0.54.0 lib/cocina/generator/schema_array.rb
cocina-models-0.54.0.beta.2 lib/cocina/generator/schema_array.rb
cocina-models-0.53.1 lib/cocina/generator/schema_array.rb
cocina-models-0.54.0.beta.1 lib/cocina/generator/schema_array.rb
cocina-models-0.53.0 lib/cocina/generator/schema_array.rb
cocina-models-0.52.0 lib/cocina/generator/schema_array.rb
cocina-models-0.51.0 lib/cocina/generator/schema_array.rb
cocina-models-0.50.0 lib/cocina/generator/schema_array.rb
cocina-models-0.49.0 lib/cocina/generator/schema_array.rb
cocina-models-0.48.0 lib/cocina/generator/schema_array.rb
cocina-models-0.47.2 lib/cocina/generator/schema_array.rb
cocina-models-0.47.1 lib/cocina/generator/schema_array.rb
cocina-models-0.47.0 lib/cocina/generator/schema_array.rb