From: Sandro Paganotti Date: 2008-04-29T19:19:45+09:00 Subject: Re: Mixins I don't know if I get the point but this seems work: module Mod @anyvar = 10 def func puts @anyvar end end class MyClass include Mod def initialize #read configuration @anyvar = 2 func() end end MyClass.new # => 2 On Tue, Apr 29, 2008 at 10:01 AM, Marcin Tyman wrote: > Hi guys!!! > My question is: > > Is any way to define variables in module which can be further used in > mixin? The problem is that module I wanted to include into class has > constant variables defined which are used within function it implements. > I'm looking for simplest way to overwrite the variables from the class > (may change the variables to non constant ones) the same meaning not to > change implementation of functions from the module. See: > > module Mod > AnyVar = 10 > > def func > #the method use AnyVar > end > end > > class MyClass > include Mod > > def initialize > #read configuration > > #how to make the function use new AnyVar value without changing its > implementation and parameters list > func() > end > end > > > Thanks a lot for any ideas. > -- > Posted via http://www.ruby-forum.com/. > > -- Go outside! The graphics are amazing!