Module: Cerealize::Codec::Marshal

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

Class Method Summary collapse

Class Method Details

.decode(str) ⇒ Object



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

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

.encode(obj) ⇒ Object



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

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

.yours?(str) ⇒ Boolean

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