module Avromatic::Model::MessagingSerialization::Decode
This module provides methods to decode an Avro-encoded value and an optional Avro-encoded key as a new model instance.
Public Instance Methods
Source
# File lib/avromatic/model/messaging_serialization.rb, line 47 def avro_message_attributes(*args) message_key, message_value = args.size > 1 ? args : [nil, args.first] key_attributes = message_key && avro_messaging.decode(message_key, schema_name: key_avro_schema.fullname) value_attributes = avro_messaging .decode(message_value, schema_name: avro_schema.fullname) value_attributes.merge!(key_attributes) if key_attributes value_attributes end
Source
# File lib/avromatic/model/messaging_serialization.rb, line 43 def avro_message_decode(*args) new(avro_message_attributes(*args)) end
If two arguments are specified then the first is interpreted as the message key and the second is the message value. If there is only one arg then it is used as the message value.