From: James Coglan Date: 2008-08-21T02:17:29+09:00 Subject: Re: Serializable Proc ------=_Part_53710_32034380.1219252865396 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline One possible stab at it (works on Ubutun, couldn't get it to work on Windows): #================================ require 'rubygems' require 'ruby2ruby' def serialize_block(&block) return nil unless block_given? klass = Class.new klass.class_eval do define_method :serializable, &block end str = RubyToRuby.translate(klass, :serializable) str.sub(/^def \S+\(([^\)]*)\)/, 'lambda { |\1|').sub(/end$/, '}') end s = serialize_block do |*args| something do args.join(', ') end end puts s #================================ Outputs: lambda { |*args| something { args.join(", ") } } This won't sort out the closure business, but will at least extract the source code of a Proc. ------=_Part_53710_32034380.1219252865396--