From: Adam Shelly Date: 2008-02-15T03:40:31+09:00 Subject: Re: lambda/procs and dynamically generated methods On 2/14/08, Chris Hall wrote: > > class JobA > > def initialize(file = nil) > raise "need file or block" if file.nil? && !block_given? > @action = block_given? ? lambda { yield } : eval("lambda { > #{IO.read(file)} }") > end > > def do > @action.call > end > end > I may be missing something important about what you are trying to accomplish, but what about simply class Job def initialize(file = nil, &block) raise "need file or block" if file.nil? && !block_given? @action = block || proc { eval IO.read(file)} end def do @action.call end end (I sure hope you trust the contents of 'file') -Adam