From: Martin DeMello Date: 2007-04-16T16:22:18+09:00 Subject: Re: suggestions needed to go DRY On 4/16/07, gaurav bagga wrote: > > def doThing var1,var2 > html_options.merge! :onclick => yield if block_given? > end > > so calling it doThing("one","two") {"methodCalledOnClick()"} did the trick > other people were happy using it doThing "one","two" This scales slightly better (think of adding several options): def doThing var1, var2 yield html_options ... end use as doThing(var1, var2) {|opts| opts[:onclick] =foo opts[:css] = bar ... } martin