On Friday 12 July 2002 02:58 pm, Patrick May wrote:
> I have a bit of code that delegates missing methods:
>
>     def method_missing( symbol, *args )
> 	delegate.send symbol, args
>     end
>
> But unfortunately, this doesn't send a block along.  How do I
> delegate a method which requires a block?  i.e., I want to delegate
> this type of method call:
>
> delegater.this_doesnt_work( "something", "blah" ) { |a, b|
>     ....
> }


class A
  def initialize(del)
    @delegate = del
  end
  def method_missing( symbol, *args )
    p symbol, args
    @delegate.send(symbol, *(args << proc { puts "in block" }))
  end
end

class B
  def someMethod(*args)
    p args
    block = args.pop
    block.call()
  end
  def someOtherMethod(*args, &block)
  end
end

b = B.new
a = A.new(b)

a.someMethod(1,2,3)

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE