It is simple to set a class constant in ruby:
CLASS_CONSTANT = “never to change”
And accessed like this:
However, I’d like to be able to create a class variable that is easily
accessible (read/write) by outside users without having to write class
accessor methods. How can I do this?
A really ugly way to set the variable without an accessor would be
class Foo; @@class_constant = “newvalue” end
but that is write only.
Foo.class_constant = “newvalue”
would be preferable, but how to do this without writing accessor