Module: Avromatic::Model::Attributes::ClassMethods

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

Instance Method Summary collapse

Instance Method Details

#add_avro_fields(generated_methods_module) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/avromatic/model/attributes.rb', line 116

def add_avro_fields(generated_methods_module)
  # models are registered in Avromatic.nested_models at this point to
  # ensure that they are available as fields for recursive models.
  register!

  if key_avro_schema
    check_for_field_conflicts!
    begin
      define_avro_attributes(key_avro_schema, generated_methods_module,
                             allow_optional: config.allow_optional_key_fields)
    rescue OptionalFieldError => ex
      raise "Optional field '#{ex.field.name}' not allowed in key schema."
    end
  end
  define_avro_attributes(avro_schema, generated_methods_module)
end