Module: Marshal

Defined in:
lib/cash/util/marshal.rb

Class Method Summary collapse

Class Method Details

.constantize(name) ⇒ Object



3
4
5
# File 'lib/cash/util/marshal.rb', line 3

def constantize(name)
  name.constantize
end

.load_with_constantize(value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/cash/util/marshal.rb', line 7

def load_with_constantize(value)
  begin
    Marshal.load_without_constantize value
  rescue ArgumentError => e
    _, class_name = *(/undefined class\/module ([\w:]*\w)/.match(e.message))
    raise if !class_name
    constantize(class_name)
    Marshal.load value
  end
end