From: Toby Clemson Date: 2008-08-27T18:08:43+09:00 Subject: Difficult Inheritance Problem Hi all, I have a problem I can't think of a solution to with regard to inheritence. I have an abstract class that others inherit from: class DataObject class << self attr_accessor :difference_mapping ... end ... end The descendents of this class each define their own difference mapping: class Page < DataObject self.difference_mapping = {:blah => :blah} end I would now like to inherit from the Page class but use its difference_mapping. Obviously this does not work because the attr_accessor in the DataObject uses a class instance variable that is unique to each class. I tried using a proper class variable (@@difference_mapping) but that is the same for all descending classes. Is there a way to define a class level variable that descends down the inheritance tree unless it is overridden in the same way as this is possible for methods? I mean I could wrap the data structure in a method but that does not seem like a very clean solution. Thanks in advance, Toby