Eric Mahurin wrote: > --- Michael Schuerig <michael / schuerig.de> wrote: >> I'm looking for a clean way to reflectively set the value of >> a class >> variable. Currently I'm using something along the lines of [snip] >> class_eval <<END >> def self.var=(value) >> @@var = value >> end >> END >> private_class_method :var= >> self.var = value >> >> Is this the way to go? > Instead of using a class variable, you could use an instance > variable of the class: > > class XYZ > def self.var=(value) > @var = value > end > def self.var > @var > end > end That's what I would probably do in the general case. As I'm using Rails in this specific case, I've settled on a variant of my example above. cattr_accessor :var private_class_method :var= self.var = value Michael -- Michael Schuerig You can twist perceptions mailto:michael / schuerig.de Reality won't budge http://www.schuerig.de/michael/ --Rush, Show Don't Tell