------ art_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 lass.new
klass.class_eval do
define_method :serializable, &block
end
str ubyToRuby.translate(klass, :serializable)
str.sub(/^def \S+\(([^\)]*)\)/, 'lambda { |\1|').sub(/end$/, '}')
end
s erialize_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.
------ art_53710_32034380.1219252865396--