2010-03-11 18:42:21 +00:00
|
|
|
module Msf
|
|
|
|
class DBManager
|
|
|
|
|
|
|
|
class Task < ActiveRecord::Base
|
|
|
|
include DBSave
|
|
|
|
|
|
|
|
belongs_to :workspace
|
2010-05-02 06:09:08 +00:00
|
|
|
#
|
|
|
|
# XXX: Factor this out to extend all of ActiveRecord::Base
|
|
|
|
#
|
|
|
|
def self.marshalize(*args)
|
|
|
|
args.each do |method_name|
|
|
|
|
method_declarations = %Q^
|
|
|
|
def #{method_name}
|
|
|
|
begin
|
|
|
|
self[:#{method_name}] ? Marshal.load(self[:#{method_name}].unpack("m")[0]) : nil
|
|
|
|
rescue ::Exception => e
|
|
|
|
# Fallback to YAML to recover old data
|
|
|
|
YAML.load(self[:#{method_name}])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def #{method_name}=(value)
|
|
|
|
self[:#{method_name}] = [Marshal.dump(value)].pack("m")
|
|
|
|
end
|
|
|
|
^
|
|
|
|
eval method_declarations
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
marshalize :options
|
|
|
|
marshalize :result
|
2010-03-11 18:42:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|