Everlasting student · Zeitwerk · Rails Core · Fukuoka Ruby Award · Ruby Hero · Freelance · Life lover
Everlasting student · Rails Core · Zeitwerk · Freelance · Life lover
Markdown supported · ⌘↵ to post
To confirm, whilst this idea won't auto discover new subclasses, it will auto-reload changes to any of the STI class files?
chaadow
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!