Module and alias_method

Hi,

is it possible, in a module, to create an alias for a method of the object including it?

module CKHTMLTableUser
alias_method :normal_init, :init
def init
if request[“action”]
send("#{request[‘action’]}_action")
end
normal_init
end
end

Doing this I get:

undefined method init' for moduleCKHTMLTableUser’

Also, the method to be triggered by “send” is also only defined in the object including the module.
Will that work once I get around the first problem?

Thanks.

Raph

Raphael Bauduin wrote:

Hi,

is it possible, in a module, to create an alias for a method of the
object including it?

module CKHTMLTableUser alias_method :normal_init, :init def init
if request[“action”]
send(“#{request[‘action’]}_action”)
end
normal_init
end
end

module CKHTMLTableUser
def self.included(cl)
cl.class_eval do
alias_method :normal_init, :init
def init
puts “init from CKHTMLTableUser”
normal_init
end
end
end
end

class C

include CKHTMLTableUser # This way won’t work.

def init
puts “init from C”
end
include CKHTMLTableUser
end

C.new.init