How do I delegate continuations?

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|

}

Thanks,

~ Patrick

patrick-may@monmouth.com (Patrick May) writes:

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:

Try

 def method_missing( symbol, *args, &block )
delegate.send symbol, args, &block
 end

Cheers

Dave

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)

···

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|

}


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

Thanks Dave and Ned! I will see how these suggestions play out in my codebase.

~ Patrick