Class: Cocina::Generator::SchemaArray
- Inherits:
-
SchemaBase
- Object
- SchemaBase
- Cocina::Generator::SchemaArray
- Defined in:
- lib/cocina/generator/schema_array.rb
Overview
Class for generating from an openapi array
Instance Attribute Summary
Attributes inherited from SchemaBase
#key, #parent, #required, #schema_doc
Instance Method Summary collapse
Methods inherited from SchemaBase
#description, #dry_datatype, #example, #filename, #initialize, #name, #quote, #string_dry_datatype
Constructor Details
This class inherits a constructor from Cocina::Generator::SchemaBase
Instance Method Details
#array_of_type ⇒ Object
19 20 21 |
# File 'lib/cocina/generator/schema_array.rb', line 19 def array_of_type schema_doc.items.name || "Types::#{dry_datatype(schema_doc.items)}" end |
#generate ⇒ Object
7 8 9 |
# File 'lib/cocina/generator/schema_array.rb', line 7 def generate "attribute :#{name.camelize(:lower)}, Types::Strict::Array.of(#{array_of_type})#{omittable}" end |
#omittable ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/cocina/generator/schema_array.rb', line 11 def omittable if required '.default([].freeze)' else '.meta(omittable: true)' end end |