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



129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/avromatic/model/attributes.rb', line 129

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

#recursively_immutable?Boolean

Returns:

  • (Boolean)


146
147
148
149
150
# File 'lib/avromatic/model/attributes.rb', line 146

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

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