chaadow Sorry, I got no notification for these comments!
That is a good idea and a version of that was documented. Problem is that it may lead to unsolvable circular dependencies that depend on load order. I am revamping the section in the guides about this topic.
Can't we use something like
Rails.autoloaders.main.on_load('MyModel') { ... }?This can be useful when applying the strategy pattern, in the same vein as having a
_stias a suffi, a team can use axxxBasesuffix.Which makes me want to ask you this question: Can we use a regular expression with the
on_loadhook?. This in combination with the_stiprefix idea, we can eager load a directory if it exists.Basically the
Baseclass will act as a router, look through the descendants and return the first applicable strategy class ( like ActiveJob::Serializers does )Do you think this is feasible? Thanks for the article!