Skip to content

Instantly share code, notes, and snippets.

@ncolgan
Created May 25, 2012 08:48
Show Gist options
  • Save ncolgan/2786710 to your computer and use it in GitHub Desktop.
Save ncolgan/2786710 to your computer and use it in GitHub Desktop.
class Plan < ActiveRecord::Base
@@sub_classes = []
cattr_reader :sub_classes
def self.inherited(child)
@@sub_classes << child
end
end
class FreePlan < Plan
end
class PaidPlan < Plan
end
# This should now return [FreePlan, PaidPlan]
Plan.sub_classes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment