Module: AnyCache::Dumper Private

Defined in:
lib/any_cache/dumper.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Since:

  • 0.4.0

Defined Under Namespace

Modules: InterfaceAccessMixin

Class Method Summary collapse

Class Method Details

.detransform_hash(hash) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • hash (Hash)

Returns:

  • (Hash)

Since:

  • 0.4.0



27
28
29
30
31
32
33
# File 'lib/any_cache/dumper.rb', line 27

def detransform_hash(hash)
  {}.tap do |entries|
    hash.each_pair do |key, value|
      entries[key] = load(value)
    end
  end
end

.dump(value) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Object)

Returns:

  • (String)

Since:

  • 0.4.0



40
41
42
43
# File 'lib/any_cache/dumper.rb', line 40

def dump(value)
  return value if value.nil?
  Zlib::Deflate.deflate(Marshal.dump(value))
end

.load(value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (String)

Returns:

  • (Object)

Since:

  • 0.4.0



50
51
52
53
# File 'lib/any_cache/dumper.rb', line 50

def load(value)
  return value if value.nil?
  Marshal.load(Zlib::Inflate.inflate(value))
end

.transform_hash(hash) ⇒ Hash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • hash (Hash)

Returns:

  • (Hash)

Since:

  • 0.4.0



14
15
16
17
18
19
20
# File 'lib/any_cache/dumper.rb', line 14

def transform_hash(hash)
  {}.tap do |entries|
    hash.each_pair do |key, value|
      entries[key] = dump(value)
    end
  end
end