Sha256: 489e04f8de03b5f299edd882897b4093b006da413b6297ac20c64448295eaf1b
Contents?: true
Size: 820 Bytes
Versions: 1
Compression:
Stored size: 820 Bytes
Contents
module Avrocado class Deserializer attr_reader :schema def initialize(schema) @schema = schema end def self.deserialize(message, schema) new(schema).deserialize(message) end def deserialize(message) Avrocado::Decoder.new(message, schema).decoded end end class Decoder attr_reader :message, :schema def initialize(message, schema) @message = message.is_a?(String) ? message.to_java_bytes : message @schema = schema end def decoded JSON.parse reader.read(nil, decoder).to_s end private def reader @reader ||= Java::Avro::GenericDatumReader.new(schema) end def decoder @decoder ||= Avrocado::DecoderFactory .default_factory .create_binary_decoder(message, nil) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
avrocado-0.2.2 | lib/avrocado/deserializer.rb |