Summary: Encode instances of objects to strings and back again
Author: John Pierce
Owner: John Pierce (jrp)
Co-maintainers: <None>
PackageInfo name: InstanceEncoder
RSS feed:


Helpers to encode and decode files or instances of any object that can be streamed (via ReferenceStream) to methods (either class or instance side).

For example, did you ever want to store a graphic as a class side method so you can share your "external" or object instances using Monticello or other code-based sharing schemes?

Well -- that is primarily what this is for. Any external file or object instance can be stuffed into a class method as a MIME-encoded zipped string.

"Store a form as a class-side method"
MyClass store: picture form asSelector: #myGraphic

"Then in the instance-side of MyClass you can access this MIME-encoded object as if it is a regular Smalltalk object"
picture := self class myGraphic

"instance variable 'picture' now is automatically reconstituted from the MIME-encoded stream"

Helpers will let you perform essentially the same technique with files (reading them and storing them as MIME-encoded strings and deploying them back to disk) as well as object instances as you saw here.