From: ts Date: 2003-04-14T23:06:44+09:00 Subject: Re: [Q] A class, that knows about it's instances + Sets >>>>> "C" == Chris Pine writes: C> My 5 minute solution (a bit of a hack) required class methods, which are C> *not* inherited when you include a module into a class, so I don't think it C> would work in your case. extend Module a stupid example with 1.8 pigeon% cat b.rb #!/usr/bin/ruby module Viv def create(*args, &block) obj = allocate if ! const_defined?(:INSTANCES) const_set(:INSTANCES,[]) end const_get(:INSTANCES) << obj obj.init (*args, &block) obj end def self.extend_object(a) a.instance_eval {define_method(:initialize) { raise "error"}} super end end class A extend Viv def init(a) @a = a end end A.new rescue p $! p A.create(12) pigeon% pigeon% ruby b.rb # # pigeon% Guy Decoux