Method: TopModel::Marshal#load

Defined in:
lib/topmodel/marshal.rb

#loadObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/topmodel/marshal.rb', line 18

def load
  return unless path
  return unless File.exist?(path)
  data = []
  File.open(path, "rb") do |file|
    begin
      data = ::Marshal.load(file)
    rescue => e
      if defined?(Bowline)
        Bowline::Logging.log_error(e)
      end
      # Lots of errors can occur during
      # marshaling - such as EOF etc
      return false
    end
  end
  data.each do |klass, records| 
    klass.marshal_records = records
  end
  true
end