Sha256: c0954aa163a7094eb3278a5883413726c0357d43723e90eb7d2069f8498ec301
Contents?: true
Size: 796 Bytes
Versions: 1
Compression:
Stored size: 796 Bytes
Contents
module Appsignal class ZippedPayload attr_reader :body def initialize(given_body) @body = Zlib::Deflate.deflate( Appsignal::ZippedPayload.json_generate(given_body), Zlib::BEST_SPEED ) end protected def self.json_generate(given_body) JSON.generate(jsonify(given_body)) end def self.jsonify(value) case value when String begin value.encode('utf-8') rescue Encoding::UndefinedConversionError '[invalid-utf8]' end when Numeric, NilClass, TrueClass, FalseClass value when Hash Hash[value.map { |k, v| [jsonify(k), jsonify(v)] }] when Array value.map { |v| jsonify(v) } else jsonify value.to_s end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
appsignal-0.11.10.beta.1 | lib/appsignal/zipped_payload.rb |