From: Scytrin dai Kinthra Date: 2008-02-13T04:13:26+09:00 Subject: Re: How to add a instance variable through a mixin? ------=_Part_1837_19285512.1202843611684 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline base.instance_variable_set('@new_ivar',nil) .included is run bound to MyMixin, not the object in base. Alternately there is usage of the *eval methods. On Feb 12, 2008 10:55 AM, MrBanabas@googlemail.com wrote: > Hi, > > I would like to have a mixin which adds an instance variable to a > class. I ve tried it the following way: > > 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. > > Maybe anybody can help me? > Thanks a lot in advance. > > -- > Volker > > > -- Adam McCall || http://stadik.net ------=_Part_1837_19285512.1202843611684--