Method: Bio::Shell::Ghost#load_object_file

Defined in:
lib/bio/shell/core.rb

#load_object_file(file) ⇒ Object



314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
# File 'lib/bio/shell/core.rb', line 314

def load_object_file(file)
  if File.exists?(file)
    STDERR.print "Loading object (#{file}) ... "
    begin
      bind = Bio::Shell.cache[:binding]
      hash = Marshal.load(File.read(file))
      hash.each do |k, v|
        begin
          Thread.current[:restore_value] = v
          eval("#{k} = Thread.current[:restore_value]", bind)
        rescue
          STDERR.puts "Warning: object '#{k}' couldn't be loaded : #{$!}"
        end
      end
    rescue
      warn "Error: Failed to load (#{file}) : #{$!}"
    end
    STDERR.puts "done"
  end
end