[Cuis-dev] Saving a CodePackage and determining its class when installing it
Nicolás Papagna Maldonado
nicolas.papagna at gmail.com
Sun Oct 25 08:04:40 PDT 2020
For some experiments I'm doing, I've created a subclass of CodePackage
(let's call it FakeCodePackage) to make my tests run fast that avoids
accessing Smalltalk or SystemOrganization.
When I filed-out the package and installed it in a fresh image, to my
surprise, the newly installed package was an instance of FakeCodePackage.
After poking around, I found this method in CodePackage that is used when
saving an instance:
"Answer the specific CodePackage subclass to use."
self class == CodePackage ifFalse: [
^ self class ].
self classesDo: [ :cls |
(cls inheritsFrom: CodePackage)
fTrue: [ ^ cls ]].
This means that whenever there is a subclass of CodePackage in the package
being saved, It is assumed that is the class that should be used to
re-creating the CodePackage instance when installing it.
In my case, FakeCodePackage is not fully functional as I use it only in my
tests, so I was unable to either delete the package or re-install it
because of all sorts of errors.
Luckily this was a fresh image, so I had nothing to lose :)
I was wondering what is the use case for that, and if it still relevant/in
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Cuis-dev