mirror of
https://github.com/bobbimanners/emailler.git
synced 2024-08-20 17:29:45 +00:00
12 lines
364 B
Ruby
12 lines
364 B
Ruby
#derived from http://ola-bini.blogspot.com/2007/07/objectspace-to-have-or-not-to-have.html
|
|
module SubclassTracking
|
|
def self.extended(klazz)
|
|
(class <<klazz; self; end).send :attr_accessor, :subclasses
|
|
(class <<klazz; self; end).send :define_method, :inherited do |clzz|
|
|
klazz.subclasses << clzz
|
|
super
|
|
end
|
|
klazz.subclasses = []
|
|
end
|
|
end
|