Sha256: c7ab5c180cc4ee991ca78ff59f86953655138aaa74eddba4047ea62298973cb2
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
# frozen_string_literal: true # @api private # @since 0.4.0 module AnyCache::Dumper require_relative 'dumper/interface_access_mixin' class << self # @param hash [Hash] # @return [Hash] # # @api private # @since 0.4.0 def transform_hash(hash) {}.tap do |entries| hash.each_pair do |key, value| entries[key] = dump(value) end end end # @param hash [Hash] # @return [Hash] # # @api private # @since 0.4.0 def detransform_hash(hash) {}.tap do |entries| hash.each_pair do |key, value| entries[key] = load(value) end end end # @param value [Object] # @return [String] # # @api private # @since 0.4.0 def dump(value) return value if value.nil? Zlib::Deflate.deflate(Marshal.dump(value)) end # @param value [String] # @return [Object] # # @api private # @since 0.4.0 def load(value) return value if value.nil? Marshal.load(Zlib::Inflate.inflate(value)) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
any_cache-0.7.0 | lib/any_cache/dumper.rb |
any_cache-0.6.0 | lib/any_cache/dumper.rb |
any_cache-0.5.0 | lib/any_cache/dumper.rb |
any_cache-0.4.0 | lib/any_cache/dumper.rb |