Skip to content

Instantly share code, notes, and snippets.

@toretore
Forked from mikebaldry/gist:1366593
Created November 15, 2011 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save toretore/1366617 to your computer and use it in GitHub Desktop.
Save toretore/1366617 to your computer and use it in GitHub Desktop.
find subclasses
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 %>
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