From: Phrogz Date: 2008-02-13T04:19:56+09:00 Subject: Re: How to add a instance variable through a mixin? On Feb 12, 11:54 am, "MrBana...@googlemail.com" wrote: > I ve defined a little module: > module MyApp > module MyMixin > def self.included(base) > @should_be_an_instance_variable = nil > end > end > end > > which is included by my little class: > class MyClass > include MyApp::MyMixin > end > > However, it seems that @should_be_an_instance_variable is currently > defined per mixin, but I would like to have a unique one for each > object of MyClass. If you mix the module in after some instances of MyClass have already been created, do you want it to dynamically create the instance variables in those instances? If you mix the module in before some instances of MyClass have been created, do you want it to run code each time a new instance is created?