Created
May 28, 2009 16:26
-
-
Save jimweirich/119418 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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