Stash is a serializer for Pharo that generate source-code.
Any object is composed of setters and getters, in Stash you define the setters and getters pairs and the serializer use them to access the object and their properties by the getter and use the setter to generate the corresponding serialized object.
Unlike Pharo's native source code generation (storeOn:, etc.), Stash also generate a readable code (as writed by a human) and manage references between objects to prevent cyclics problems.
Stash go through five differents steps:
Using the getters to reference all objects and count the occurences they appears in the graph of element (cyclic references management).
During this step Stash will name each objects. Objects that need to be referenced are given unique name. For example if an object appears more than two times, Stash will create a variable in the futur source code to contains it.
Stash write variables between "pipes" ||.
During this step, Stash affect variables with referenced objects.
This step generate all the expected source-code.
"Instanciate a test object with a test class"
object := StashTestSetterGetter1 new name: 'hello'; yourself.
"Serialize the object as a String"
string := Stash new serialize: object.
string value is:
StashTestSetterGetter1 new
name: 'hello';
yourself
Use "Do It" on the generated code in a playground or materialize it:
"Programmaticaly"
object := Stash new materialize: string.
| stashtestsettergetter11 |
object := StashTestSetterGetter1 new.
object name: object;
yourself.
Stash new serialize: object.
Metacello new
baseline: 'StashSerialization';
repository: 'github://Nyan11/Stash:master/src';
load