lib/mongo_mapper/plugins/sci.rb in mongo_mapper-0.13.0.beta2 vs lib/mongo_mapper/plugins/sci.rb in mongo_mapper-0.13.0
- old
+ new
@@ -8,15 +8,17 @@
extend ActiveSupport::DescendantsTracker
end
module ClassMethods
def inherited(subclass)
- key :_type, String unless key?(:_type)
super
if @collection_name == subclass.instance_variable_get("@collection_name")
+ key :_type, String unless key?(:_type)
subclass.single_collection_parent = self
subclass.instance_variable_set("@single_collection_inherited", true)
+ else
+ remove_key :_type
end
end
def single_collection_root
parent = single_collection_parent || self
@@ -38,9 +40,10 @@
end
end
def set_collection_name(name)
if single_collection_inherited?
+ single_collection_parent.remove_key :_type
single_collection_parent = nil
@single_collection_inherited = false
end
@collection_defined = true
super