Hi --

On Thu, 17 Jan 2002, Jim Freeze wrote:

> Hi:
>
> I have a module with a module method written as:
>
> module MyModule
>
>   def self.old
>     # code here
>   end#sef.old
>
> end#module MyModule
>
> I would like to alias this method.
> However, this does NOT work:
>
> module MyModule
>
>   def self.old
>     # code here
>   end#sef.old
>   aliase :self.new :self.old
>
> end#module MyModule

You have to do the aliasing in the context of the class of MyModule:

  module MyModule
    def self.old
      puts "hi"
    end
    class << self
    alias :oldold :old
    end
  end
  MyModule.old     # hi
  MyModule.oldold  # hi

You could even do:

  module MyModule
    class << self
    def old
      puts "hi"
    end
    alias :oldold :old
    end
  end

(I'm sort of assuming that you don't really want to alias the method
to 'new' -- ?)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav