Class: Avrocado::Serializer
- Inherits:
-
Object
- Object
- Avrocado::Serializer
- Defined in:
- lib/avrocado/serializer.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, schema = Schema.parse) ⇒ Serializer
constructor
A new instance of Serializer.
- #serialize ⇒ Object
Constructor Details
#initialize(message, schema = Schema.parse) ⇒ Serializer
Returns a new instance of Serializer.
5 6 7 8 |
# File 'lib/avrocado/serializer.rb', line 5 def initialize(, schema = Schema.parse) @message = @schema = schema end |
Instance Attribute Details
#message ⇒ Object (readonly)
Returns the value of attribute message.
3 4 5 |
# File 'lib/avrocado/serializer.rb', line 3 def @message end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
3 4 5 |
# File 'lib/avrocado/serializer.rb', line 3 def schema @schema end |
Class Method Details
.serialize(message) ⇒ Object
10 11 12 |
# File 'lib/avrocado/serializer.rb', line 10 def self.serialize() new().serialize end |
Instance Method Details
#serialize ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/avrocado/serializer.rb', line 14 def serialize .each do |field, value| record.put(field.to_s, value) end writer.write(record, encoder) encoder.flush output.to_byte_array end |