lib/rocket_job/sliced/compressed_slice.rb in rocketjob-5.1.1 vs lib/rocket_job/sliced/compressed_slice.rb in rocketjob-5.2.0.beta1

- old
+ new

@@ -1,26 +1,26 @@ -require 'zlib' +require "zlib" module RocketJob module Sliced # Compress the records within a slice class CompressedSlice < ::RocketJob::Sliced::Slice private def parse_records - records = attributes.delete('records') + records = attributes.delete("records") # Convert BSON::Binary to a string binary_str = records.data str = Zlib::Inflate.inflate(binary_str) - @records = Hash.from_bson(BSON::ByteBuffer.new(str))['r'] + @records = Hash.from_bson(BSON::ByteBuffer.new(str))["r"] end def serialize_records return [] if @records.nil? || @records.empty? # Convert slice of records into a single string - str = {'r' => records.to_a}.to_bson.to_s + str = {"r" => records.to_a}.to_bson.to_s data = Zlib::Deflate.deflate(str) BSON::Binary.new(data) end end