Is there such a thing?
Rails’ ActiveSupport provides them as cattr_* and mattr_*. For that
matter, they’re not that hard to write. For that matter, what Eric said.
Is there such a thing?
Rails’ ActiveSupport provides them as cattr_* and mattr_*. For that matter,
they’re not that hard to write. For that matter, what Eric said.
I’d add that if you write them (and I agree with Eric that instance
variables are much better for this; indeed, something is pretty much
always better than class variables for everything), it’s best to name
them something else. “attr” names suggest an attribute of an object,
but since class variables are not uniquely associated with any one
object, they’re not a good fit for recording an attribute.
David
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.