From: Jean-Hugues ROBERT Date: 2004-04-28T04:51:53+09:00 Subject: Re: yaml doesn't save Proc members At 02:49 22/04/2004 +0900, you wrote: >Dick Davies wrote: > >>I thought I'd bugger about with YAML to save and load the tree, >>but although the arrays all get laid down nicely, the blocks don't. >>When I call to_yaml, the proc is saved as an empty block, >>and when YAML.load() tries to pull it back, I get: >>NoMethodError: allocator undefined for Proc > >I've written some code which will allow to serialize Procs under specific >conditions. It's limited and won't work with everything even if it were >more complete than my current version. > >It might however be able to do what you want, in this case. > >Anyway, it's available at >http://noegnud.sourceforge.net/flgr/proc_source.rb -- it might be worth a try. > >Regards, >Florian Gross I had a look at it. It basically uses Proc##inspect() to get the file/line where the proc is defined. Then, using IRB's Lexer, the proc's definition is grabbed. Some additional stuff handles cases where proc isn't defined in a file (if def in some eval() for example). I liked the code and I am injecting it (after some major refactoring) in my own code. Yamlizing Proc/s is for sure cool. Thanks Florian. ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17