Open up Super
's singleton class and give that a regular attr_accessor
:
class Super
class << self
attr_accessor :name
end
end
That should give you the semantics you want: a "class level instance variable".
However I'll note that any value set for :name
on Super
will not be inherited by Super
's children. This makes sense if you think about it: the children inherit the attr_accessor
, not the attribute itself.
There are some ways around this, most notably rails provides class_attribute
which provides the ability of children to inherit the value of the parent's attribute unless explicitly overridden.