So I have a Superclass (which for simplicity I'll call), Mammal, from which classes Dog, Monkey, and Bear inherit methods. Some of the inherited methods return an object that needs to be of the same class it is called from. For example, Dog.find(...) should return Dog objects. But because the find() method is inherited from Mammal, the method can't be coded to explicitly return Dog(...). It would need to be able to return Dog, Monkey, Bear, or Mammal objects, depending on the value of self.__class__.__name__.
I've achieved this with return eval(self.__class__.__name__)(...), but I'd prefer to avoid using eval. Is there a better way?
dog.name = 'Rex'and thendog.save()to update it in the table. This leaves me needing a class that can return Dog objects based on find conditions, but I feel like this is too specialized for the DB wrapper class to do. I'm not the best at class design.