Mixins and initialize/initialize_copy

  • Thread starter Rüdiger Sonderfeld
  • Start date
R

Rüdiger Sonderfeld

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 <[email protected]>
 
T

Trans

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.
 
F

Florian Frank

R=C3=BCdiger Sonderfeld said:
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 ini= tialize
and/or initialize_copy, too.

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

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

What would be the best solution to this problem?
=20
Calling super from the instance methods of your class?

--=20
Florian Frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top