On Thu, Aug 24, 2006 at 01:45:40AM +0900, James Edward Gray II wrote:
> On Aug 23, 2006, at 11:11 AM, Nathan Smith wrote:
> 
> >I think he's wanting to know if it's possible to call a different  method
> >of the superclass than the method that the interpreter is in.
> 
> I'm not sure it's a great idea, but sure you can:
> 
> def send_super(meth, *args, &blk)
>   # hide current method
>   if self.class.instance_methods(false).include? meth.to_s
>     self.class.send(:alias_method, :_hidden, meth)
>     self.class.send(:remove_method, meth)
>   end
> 
>   send(meth, *args, &blk)
> ensure
>   self.class.send(:alias_method, meth, :_hidden) if methods.include? "_hidden"
> end

wow, that's way too much work (plus thread-unsafe).

def send_super(meth, *args, &b)
  self.class.superclass.instance_method(meth).bind(self).call(*args, &b)
end


RUBY_VERSION                                       # => "1.8.5"
RUBY_RELEASE_DATE                                  # => "2006-07-07"
class Parent
  def a
    "Hello from Parent!"
  end
end

class Child < Parent
  def a
    "Hello from Child!"
  end

  def b
    send_super(:a)
  end
end

child = Child.new
puts child.b
puts child.a

__END__
# >> Hello from Parent!
# >> Hello from Child!


-- 
Mauricio Fernandez  -   http://eigenclass.org   -  singular Ruby