Sha256: d50563dec79ab311448b9f9854bb15ae545731369a214f30281c300b133c66f3
Contents?: true
Size: 755 Bytes
Versions: 11
Compression:
Stored size: 755 Bytes
Contents
# frozen_string_literal: true module Paquito class SingleBytePrefixVersion def initialize(current_version, coders) @current_version = current_version @coders = coders.transform_values { |c| Paquito.cast(c) } @current_coder = coders.fetch(current_version) end def dump(object) @current_version.chr(Encoding::BINARY) << @current_coder.dump(object) end def load(payload) payload_version = payload.getbyte(0) unless payload_version raise UnsupportedCodec, "Missing version byte." end coder = @coders.fetch(payload_version) do raise UnsupportedCodec, "Unsupported packer version #{payload_version}" end coder.load(payload.byteslice(1..-1)) end end end
Version data entries
11 entries across 11 versions & 1 rubygems