Skip to content

Instantly share code, notes, and snippets.

@sheldonh
Created July 22, 2010 13:34
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 sheldonh/485965 to your computer and use it in GitHub Desktop.
Save sheldonh/485965 to your computer and use it in GitHub Desktop.
--- a/lib/mongoid/document.rb
+++ b/lib/mongoid/document.rb
@@ -11,6 +11,15 @@ module Mongoid #:nodoc:
attr_reader :new_record
delegate :primary_key, :to => "self.class"
+
+ unless self.instance_of?(Class) and self.name == ""
+ (@@descendants ||= {})[self] = :seen
+ end
+ end
+
+ # Returns the classes that have included Mongoid::Document
+ def self.descendants
+ (@@descendants ||= {}).keys
end
module ClassMethods #:nodoc:
@jacquescrocker
Copy link

merged. Thanks dude!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment