Forum: Ruby Mixins and initialize/initialize_copy

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
9279a287c8b8f1ecb1aa4beca1002888?d=identicon&s=25 unknown (Guest)
on 2006-04-04 15:26
(Received via mailing list)
I have created a mixin module that overwrites initialize and
This works fine until a class that uses the mixin wants to overwrite
and/or initialize_copy, too.

I can replace initialize with lazy accessors. But I don't know how to

The mixin manages some attributes and the initialize_copy method makes
that cloning the object clones the managed attributes.

What would be the best solution to this problem?

Rüdiger Sonderfeld <>
45196398e9685000d195ec626d477f0e?d=identicon&s=25 Trans (Guest)
on 2006-04-04 17:14
(Received via mailing list)
Anyone who does this kind of thing should always check to see if the
method is already defined and if it is wrap it --NEVER just overwrite
these instrumental methods.

D84df7c68f790e492c4ad4ec5fe65547?d=identicon&s=25 Florian Frank (Guest)
on 2006-04-04 21:38
(Received via mailing list)
Rüdiger Sonderfeld wrote:

>What would be the best solution to this problem?
Calling super from the instance methods of your class?
This topic is locked and can not be replied to.