On Fri, Jan 28, 2011 at 10:45 PM, Dagnan <dagnan / gmail.com> wrote:
> I'm trying to alias a method in a module and then overwriting this method (still having access to the old method).

try

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 initialize(*args)
  self.extend Foo::Overrider
 end

 module Overrider
   def foo
     puts 'foobar'
     #old_foo
   end
 end


end

A.send :include, Foo

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

not just sure if that is the best way for modifying a class instance
methods. i'd rather just use require if possible ...

best regards -botp