I think this one is prettier (but maybe not as sophisticated):
module Enumerable def method_missing(sym, *args) if (sym.to_s =~ /^(.+)_with$/) && (msg = args.shift) send($1.to_sym) do |x| x.send(msg, *args) end end end end [1, 2, 3].map_with :to_s
12392 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
module Enumerable def method_missing(sym, *args) if (sym.to_s =~ /^(.+)_with$/) && (msg = args.shift) send($1.to_sym) do |x| x.send(msg, *args) end end end end [1, 2, 3].map_with :to_s
You need to create an account or log in to post comments to this site.