[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Mixins and initialize/initialize_copy

kingruedi

4/4/2006 1:22:00 PM

Hello,
I have created a mixin module that overwrites initialize and initialize_copy.
This works fine until a class that uses the mixin wants to overwrite initialize
and/or initialize_copy, too.

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

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

What would be the best solution to this problem?

Regards,
Rüdiger Sonderfeld <kingruedi@c-plusplus.de>
2 Answers

Trans

4/4/2006 3:11:00 PM

0

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.

T.

Florian Frank

4/4/2006 7:38:00 PM

0

Rüdiger Sonderfeld wrote:

>I have created a mixin module that overwrites initialize and initialize_copy.
>This works fine until a class that uses the mixin wants to overwrite initialize
>and/or initialize_copy, too.
>
>I can replace initialize with lazy accessors. But I don't know how to handle
>initialize_copy:
>
>The mixin manages some attributes and the initialize_copy method makes sure
>that cloning the object clones the managed attributes.
>
>What would be the best solution to this problem?
>
>
Calling super from the instance methods of your class?

--
Florian Frank