I ran into a similar problem using Madeleine.  In Madeleine, you need to
have the objects referenced all the time, so ObjectSpace won't work.

My 5 minute solution (a bit of a hack) required class methods, which are
*not* inherited when you include a module into a class, so I don't think it
would work in your case.  Here it is, anyway.  Anyone have any more elegant
ideas?


  class Parent
    def self.create (*params)
      obj = new :afdifw489r3k4jge98  #  Just bang on the keyboard.

      #  Set constant in child class.
      if const_get(:INSTANCES).nil?
        const_set(:INSTANCES,[])
      end
      const_get(:INSTANCES) << obj

      obj.init (*params)
    end

    def initialize fromCreateKey
      raise 'Illegal object creation.' if fromCreateKey !=
:afdifw489r3k4jge98
    end
  end

  class Child < Parent
    def init foo, bar, whatever
      #  Initialization code moved to here.
      #  Don't override `initialize'.
    end
  end


Chris