please forgive the typos in the original, i should learn not to type the 
code directly into the form.


corrected:


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

class JobB

  def initialize(file = nil)
    raise "need file or block" if file.nil? && !block_given?
    action = block_given? ? lambda { yield } : eval("lambda { 
#{IO.read(file)} }")
    self.class.send(:define_method, :task, action)
    self.class.send(:private, :task)
  end

  def do
    task
  end
end

-- 
Posted via http://www.ruby-forum.com/.