Module: Avromatic::Model::MessagingSerialization::Decode
- Included in:
- ClassMethods
- Defined in:
- lib/avromatic/model/messaging_serialization.rb
Overview
This module provides methods to decode an Avro-encoded value and an optional Avro-encoded key as a new model instance.
Instance Method Summary collapse
- #avro_message_attributes(*args) ⇒ Object
-
#avro_message_decode(*args) ⇒ Object
If two arguments are specified then the first is interpreted as the message key and the second is the message value.
Instance Method Details
#avro_message_attributes(*args) ⇒ Object
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/avromatic/model/messaging_serialization.rb', line 47 def (*args) , = args.size > 1 ? args : [nil, args.first] key_attributes = && avro_messaging.decode(, schema_name: key_avro_schema.fullname) value_attributes = avro_messaging .decode(, schema_name: avro_schema.fullname) value_attributes.merge!(key_attributes) if key_attributes value_attributes end |
#avro_message_decode(*args) ⇒ Object
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.
43 44 45 |
# File 'lib/avromatic/model/messaging_serialization.rb', line 43 def (*args) new((*args)) end |