[@Max: our messages just crossed. With all due respect, I think I like
my approach better!]
Okay. I’m out of the weeds, but I’d like to know if I’ve done it the
My code references subclasses of MeteredService several transactions
after metered_service.rb gets loaded (e.g. the result of posting a
form), at which point the sub-classes had been flushed and there was
nothing that forced a reload of metered_service.rb. Ergo, adding
require_dependency statements at the bottom of metered_service.rb didn’t
My next gambit was to overload MeteredService.descendants:
… but that had the problem that it threw “TypeError (superclass
mismatch for class PGEBusiness)” when it got called. Perhaps it’s in
the wrong context when it calls require_dependency? I don’t know, and I
couldn’t find any documentation that helped.
So now I overload MeteredService.descendants, calling ‘require’ instead
of ‘require_dependency’. This seems to work just fine:
Yes, I will generalize this with a method that reads the contents of the
metered_services directory so I don’t have to manually add each one.
Let me know if I’m missing anything important.