salsify / avromatic

Generate Ruby models from Avro schemas
MIT License
89 stars 17 forks source link

Load the nested models of eager loaded models #119

Closed jcmfernandes closed 4 years ago

jcmfernandes commented 4 years ago

Generated nested models register themselves upon being created by Avromatic::Model::Builder. If Rails's autoloader didn't recreate a model that should be eager loaded, then its nested models won't be registered as we hook on Railtie #to_prepare that itself triggers a clean-up of the nested models registry.

Therefore, we have to go through the attribute definitions of each eager loaded model and try to register its nested models.

prime @jturkel

jcmfernandes commented 4 years ago

Hey @jturkel, I did some changes based on your feedback. Let me know what you think. Thanks!

jcmfernandes commented 4 years ago

Alright, all done! 😉