From: Ezra Zygmuntowicz Date: 2007-02-09T15:30:57+09:00 Subject: Re: How to "pass" the current binding's block to some other method? On Feb 8, 2007, at 4:33 PM, Lyle Johnson wrote: > On 2/8/07, Joel VanderWerf wrote: > >> Does this help? >> >> class Foo >> def try(x, y, z) >> # ... do some other stuff first ... >> yield self if block_given? >> end >> >> alias old_try try >> def try(hash) >> old_try(hash[:x], hash[:y], hash[:z]) do >> yield self if block_given? >> end >> end >> end >> >> Foo.new.try({}) do puts "trying" end > > Ah, yes, that ought to do the trick too. Thanks! > def try(x, y, z) # ... do some other stuff first ... yield self if block_given? end alias old_try try def try(hash) old_try(hash[:x], hash[:y], hash[:z], &yield) end try( :a => 'foo') { puts 'hi' } Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)