Catching super() with method_missing

Hello,

I was recently surprised to find that I can’t do:

class Outer
def method_missing(methID, *args, &block)
p methID.id2name
end
end

class Inner < Outer
def foo
super
end
end

obj = Inner.new
obj.foo

It raises: “super: no superclass method `foo’ (NameError)”

Is this behavior intentional? Why should super() assume that we won’t
catch the undefined method with method_missing? If this isn’t a bug, is
there another way to accomlish this same thing - namely, to have a
top-level class which filters all undefined methods and have subclasses
which sometimes overload those methods but still may need to pass the
method on to the superclass?

Thanks,
-Brad

stranger still that this does work :

class Outer
def method_missing(methID, *args, &block)
p methID.id2name
end
end

class Inner < Outer
def foo
super
end
end

o = Outer.new
o.foo
obj = Inner.new
obj.foo

-a

···

On Sat, 8 Feb 2003, Brad Hilton wrote:

Hello,

I was recently surprised to find that I can’t do:

class Outer
def method_missing(methID, *args, &block)
p methID.id2name
end
end

class Inner < Outer
def foo
super
end
end

obj = Inner.new
obj.foo

It raises: “super: no superclass method `foo’ (NameError)”

====================================

Ara Howard
NOAA Forecast Systems Laboratory
Information and Technology Services
Data Systems Group
R/FST 325 Broadway
Boulder, CO 80305-3328
Email: ahoward@fsl.noaa.gov
Phone: 303-497-7238
Fax: 303-497-7259
====================================

Hi,

···

In message “catching super() with method_missing” on 03/02/08, Brad Hilton bhilton@vpop.net writes:

I was recently surprised to find that I can’t do:

class Outer
def method_missing(methID, *args, &block)
p methID.id2name
end
end

class Inner < Outer
def foo
super
end
end

obj = Inner.new
obj.foo

It raises: “super: no superclass method `foo’ (NameError)”

Is this behavior intentional? Why should super() assume that we won’t
catch the undefined method with method_missing?

No, I couldn’t think of a case like this. It will be fixed.
Thank you.

						matz.