M
Michael Schuerig
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
class_eval("@@var = #{value.inspect}")
which I don't like much. There is no class_variable_set, but, so I
thought, maybe instance variables of the class object are treated as
class variables, thus I tried
klass.instance_variable_set@@var, value)
`@@var' is not allowed as an instance variable name
So, this doesn't work. Then there's
class_eval <<END
def self.var=(value)
@@var = value
end
END
private_class_method :var=
self.var = value
Is this the way to go?
Michael
variable. Currently I'm using something along the lines of
class_eval("@@var = #{value.inspect}")
which I don't like much. There is no class_variable_set, but, so I
thought, maybe instance variables of the class object are treated as
class variables, thus I tried
klass.instance_variable_set@@var, value)
`@@var' is not allowed as an instance variable name
So, this doesn't work. Then there's
class_eval <<END
def self.var=(value)
@@var = value
end
END
private_class_method :var=
self.var = value
Is this the way to go?
Michael