Module: ODBA::Marshal

Defined in:
lib/odba/marshal.rb

Overview

Marshal is a simple extension of ::Marshal. To be able to store our data using the DBI-Interface, we need to escape invalid characters from the standard binary dump.

Class Method Summary collapse

Class Method Details

.dump(obj) ⇒ Object



9
10
11
12
# File 'lib/odba/marshal.rb', line 9

def self.dump(obj)
  binary = ::Marshal.dump(obj)
  binary.unpack1("H*")
end

.load(hexdump) ⇒ Object



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

def self.load(hexdump)
  binary = [hexdump].pack("H*")
  ::Marshal.load(binary)
rescue => error
  warn "#{error}: hexdump is #{hexdump.inspect} #{error.backtrace.join("\n")}"
  Date.new
end