Class: Cocina::Generator::SchemaValue

Inherits:
SchemaBase
  • Object
show all
Defined in:
lib/cocina/generator/schema_value.rb

Overview

Class for generating from an openapi value

Instance Attribute Summary

Attributes inherited from SchemaBase

#key, #lite, #nullable, #parent, #relaxed, #required, #schema_doc, #schemas

Instance Method Summary collapse

Methods inherited from SchemaBase

#any_datatype?, #custom_type?, #datatype_from_doc_names, #datatype_from_doc_type, #defined_datatypes?, #deprecation, #description, #dry_datatype, #example, #filename, #initialize, #name, #optional, #preamble, #quote, #relaxed_comment, #string_dry_datatype

Constructor Details

This class inherits a constructor from Cocina::Generator::SchemaBase

Instance Method Details

#generateObject



7
8
9
10
11
12
13
# File 'lib/cocina/generator/schema_value.rb', line 7

def generate
  if required && !relaxed
    "#{preamble}attribute :#{name.camelize(:lower)}, #{type}"
  else
    "#{preamble}attribute? :#{name.camelize(:lower)}, #{type}"
  end
end