Module: Avromatic::Model::RawSerialization::Decode

Included in:
ClassMethods
Defined in:
lib/avromatic/model/raw_serialization.rb

Instance Method Summary collapse

Instance Method Details

#avro_raw_decode(key: nil, value:, key_schema: nil, value_schema: nil) ⇒ Object

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.



121
122
123
124
125
126
# File 'lib/avromatic/model/raw_serialization.rb', line 121

def avro_raw_decode(key: nil, value:, 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