I want to mixin a class, overwrite the initialize method, but I still want to call the original initialize, how can I do this as simple as possible?
class A def initialize #some code endend
module B def initialize #some way to call the original #some other code endend #then extend
A.include(B)
In your module, you'll need to override the module's "self.included" hook.
This gets passed the constant for the class you are being mixed into.
In the included hook, alias the original initialize to some other method
name. Then, create your own initialize method. In the new initialize method,
call the alias to the original initialize method.
ยทยทยท
2011/3/3 pp <tdihp@hotmail.com>
I want to mixin a class, overwrite the initialize method, but I still want
to call the original initialize, how can I do this as simple as possible?
class A def initialize #some code endend
module B def initialize #some way to call the original #some other code endend #then extend
A.include(B)