Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Created May 28, 2009 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimweirich/119418 to your computer and use it in GitHub Desktop.
Save jimweirich/119418 to your computer and use it in GitHub Desktop.
module ConcernedParent
module ClassMethods
def children
@children ||= []
end
def inherited(cls)
children << cls
end
end
def self.included(cls)
cls.extend(ClassMethods)
end
end
class Parent
include ConcernedParent
end
class Child1 < Parent
end
class Child2 < Parent
end
puts Parent.children
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment