Class: Horcrux::GzipSerializer
- Inherits:
-
Object
- Object
- Horcrux::GzipSerializer
- Defined in:
- lib/horcrux/serializers/gzip_serializer.rb
Instance Method Summary collapse
- #dump(value) ⇒ Object
-
#initialize(serializer) ⇒ GzipSerializer
constructor
A new instance of GzipSerializer.
- #load(value) ⇒ Object
Constructor Details
#initialize(serializer) ⇒ GzipSerializer
6 7 8 |
# File 'lib/horcrux/serializers/gzip_serializer.rb', line 6 def initialize(serializer) @serializer = serializer end |
Instance Method Details
#dump(value) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/horcrux/serializers/gzip_serializer.rb', line 10 def dump(value) s = StringIO.new z = Zlib::GzipWriter.new(s) z.write @serializer.dump(value) s.string ensure z.close if z end |
#load(value) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/horcrux/serializers/gzip_serializer.rb', line 19 def load(value) s = StringIO.new(value) z = Zlib::GzipReader.new(s) @serializer.load(z.read) ensure z.close if z end |