Class: DRbQS::Worker::Serialize
- Inherits:
-
Object
- Object
- DRbQS::Worker::Serialize
- Defined in:
- lib/drbqs/worker/serialize.rb
Defined Under Namespace
Classes: Unpacker
Constant Summary collapse
- HEADER_BYTE_SIZE =
4
Class Method Summary collapse
Class Method Details
.dump(obj) ⇒ Object
54 55 56 57 |
# File 'lib/drbqs/worker/serialize.rb', line 54 def self.dump(obj) str = Marshal.dump(obj) [str.size].pack('N') << str end |
.load(s) ⇒ Object
59 60 61 62 63 |
# File 'lib/drbqs/worker/serialize.rb', line 59 def self.load(s) size = s[0, HEADER_BYTE_SIZE].unpack('N')[0] data = s[HEADER_BYTE_SIZE, size] Marshal.load(data) end |