On 2/14/08, Chris Hall <christopher.k.hall / gmail.com> 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