lib/avromatic/model/raw_serialization.rb in avromatic-3.0.2 vs lib/avromatic/model/raw_serialization.rb in avromatic-4.0.0
- old
+ new
@@ -34,10 +34,11 @@
unless validate == UNSPECIFIED
ActiveSupport::Deprecation.warn("The 'validate' argument to #{__method__} is deprecated.")
end
raise 'Model has no key schema' unless key_avro_schema
+
avro_raw_encode(key_attributes_for_avro, :key)
end
def value_attributes_for_avro(validate: UNSPECIFIED)
unless validate == UNSPECIFIED
@@ -116,11 +117,11 @@
# Create a new instance based on an encoded value and optional encoded key.
# If supplied then the key_schema and value_schema are used as the writer's
# schema for the corresponding value. The model's schemas are always used
# as the reader's schemas.
- def avro_raw_decode(key: nil, value:, key_schema: nil, value_schema: nil)
+ def avro_raw_decode(value:, key: nil, key_schema: nil, value_schema: nil)
key_attributes = key && decode_avro_datum(key, key_schema, :key)
value_attributes = decode_avro_datum(value, value_schema, :value)
value_attributes.merge!(key_attributes) if key_attributes
new(value_attributes)
end
@@ -148,13 +149,13 @@
Avromatic.use_custom_datum_writer ? Avromatic::IO::DatumWriter : Avro::IO::DatumWriter
end
def datum_writer
@datum_writer ||= begin
- hash = { value: datum_writer_class.new(value_avro_schema) }
- hash[:key] = datum_writer_class.new(key_avro_schema) if key_avro_schema
- hash
- end
+ hash = { value: datum_writer_class.new(value_avro_schema) }
+ hash[:key] = datum_writer_class.new(key_avro_schema) if key_avro_schema
+ hash
+ end
end
def datum_reader
@datum_reader ||= begin
hash = { value: datum_reader_class.new(value_avro_schema) }