-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Attributes
-
None
Currently Mongoid declares _type fields on the parent and each child when single collection inheritance is used. Each of these _type fields has a fixed default which is the class name that the field is declared on.
Instead we could declare the field only on the parent class and use a Proc as the default value which would determine the correct value to write into the field at runtime based on the actual class that is being instantiated.
Comments in the code refer to declaring fields in child classes for backwards compatibility, but either this would still happen or there isn't relevant test coverage that I can find.