On Mar 1, 11:35 am, Gary Wright <gwtm... / mac.com> wrote:
> ...
> I think you are asking for something which is quite easy:
>
> class A
>    class <<self
>      attr_accessor :per_class
>    end
> end
> ...

Yes, this is kind of what I'm referring to; however, my gripe is that
this is somewhat esoteric.  The beauty of other parts of Ruby is that
the code is terse and readable.  Also, I think that the work-around
that you mentioned (and I've used too) does not truly inherit:

class A
   class <<self
     attr_accessor :per_class
   end
end

A.per_class  #=> 1

class B < A
end

B.per_class  #=> nil

Something that is unique to a class but inherits with nice syntax is
what I'd like to see (and I'm fairly sure is the behavior used in
other OOP languages).  For example, assume that the behavior that I'm
referring to uses a triple "@" prefix to initialize ("@@@").  Then:

class A
   @@@per_class = 1
   attr_accessor :per_class
end

A.per_class         #=> 1

class B < A
end

B.per_class         #=> 1
B.per_class = 2     #=> 2
A.per_class         #=> 1

I've read about this in postings before; however, I'm not aware of any
efforts made to support this behavior natively.  I'm hoping that this
feature is being considered or hopefully worked on.  I've had the need
for this on more than one occasion.

Thanks,
-James