From: Paul Brannan Date: 2001-10-04T06:35:19+09:00 Subject: [ruby-talk:22031] Re: Marshal won't dump a Proc How about the following? The only major disadvantage is that it will be a little bit slower than using a real Proc: require 'delegate' class DumpableProc < DelegateClass(Proc) def initialize(str) eval "@proc = proc { #{str} }" @str = str super(@proc) end def _dump(limit) @str end def self._load(str) self.new(str) end end dp = DumpableProc.new("puts 'foo!'") dp.call() dump_str = Marshal.dump(dp) puts dump_str dp2 = Marshal.load(dump_str) dp2.call()