On Jan 4, 2008, at 14:44 , Giles Bowkett wrote: > If you think about it the problem is obvious. Here's the code. > > def generate(&block) > code = "" > statements_in_the_block(block).each do |statement| > code << Generators.module_eval(statement) > end > code > end > def statements_in_the_block(block) > statements = /proc \{\n(.+)\}/m.match(block.to_ruby)[1].split(/ > \n/) > statements.map {|statement| statement.gsub!(/^\s+/, "")} > statements.map {|statement| statement.gsub!(/\s+/, " ")} > statements > end I still don't understand the 1-line obsession... and yes, that is naive, it'll break on strings, sub-procs, pretty much all blocks, etc. You can't treat "statements" in ruby as each line of a block. #to_ruby is probably not what you want.