Hi.

I'm trying to alias a method in a module and then overwriting this method (still having access to the old method).

I tried the following code that does not seem to work with Ruby 1.9.2. Do you have an idea why?

Thanks.

class A
  def foo
    puts 'bar'
  end
end

module Foo
  def self.included(base)
    base.class_eval do
      alias_method :old_foo, :foo #unless method_defined?(:old_foo)
    end
  end

  def foo
    puts 'foobar'
    #old_foo
  end
end

A.send :include, Foo

a = A.new
a.foo #=> bar