Module: Cerealize::Codec::Marshal

Defined in:
lib/cerealize/codec/marshal.rb

Class Method Summary (collapse)

Class Method Details

+ (Object) decode(str)



17
18
19
# File 'lib/cerealize/codec/marshal.rb', line 17

def decode(str)
  Marshal.load(str.unpack('m*').first)
end

+ (Object) encode(obj)



13
14
15
# File 'lib/cerealize/codec/marshal.rb', line 13

def encode(obj)
  [Marshal.dump(obj)].pack('m*')
end

+ (Boolean) yours?(str)

Version 4.8 of Marshalize always base64s to "BA" TODO: extract base64 decorator, then we can use pure marshal

Returns:

  • (Boolean)


9
10
11
# File 'lib/cerealize/codec/marshal.rb', line 9

def yours?(str)
  str[0..1] == 'BA'
end