Method: Avromatic::Model::Validation#missing_avro_attributes

Defined in:
lib/avromatic/model/validation.rb

#missing_avro_attributesObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/avromatic/model/validation.rb', line 52

def missing_avro_attributes
  return @missing_attributes if instance_variable_defined?(:@missing_attributes)

  missing_attributes = []

  self.class.attribute_definitions.each_value do |attribute_definition|
    value = send(attribute_definition.name)
    field = attribute_definition.field
    if value.nil? && field.type.type_sym != :null && attribute_definition.required?
      missing_attributes << field.name
    else
      missing_attributes.concat(Avromatic::Model::Validation.missing_nested_attributes(field.name, value))
    end
  end

  @missing_attributes = missing_attributes.freeze if recursively_immutable?

  missing_attributes
end