-
-
Save toretore/1366617 to your computer and use it in GitHub Desktop.
find subclasses
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
class PullSource | |
def self.implementations | |
@implementations ||= {} | |
end | |
def self.register(name) | |
implementations[name] << self | |
end | |
end | |
class SomePullSource < PullSource | |
register 'Some name' | |
end | |
<%= select_whatever PullSource.implementations.keys %> |
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
class PullSource | |
def self.subclasses | |
@subclasses ||= [] | |
end | |
def self.inherited(sub) | |
subclasses << sub | |
end | |
end | |
class SomePullSource < PullSource | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment