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



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/avromatic/model/attributes.rb', line 141

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 => e
      raise "Optional field '#{e.field.name}' not allowed in key schema."
    end
  end
  define_avro_attributes(avro_schema, generated_methods_module)
end

#recursively_immutable?Boolean

Returns:

  • (Boolean)


158
159
160
161
162
# File 'lib/avromatic/model/attributes.rb', line 158

def recursively_immutable?
  return @recursively_immutable if defined?(@recursively_immutable)

  @recursively_immutable = immutable? && attribute_definitions.each_value.all?(&:values_immutable?)
end