ShapeChangers

ShapeChanger enables you to read class shape changed instances. It supports renamed, removed and newly added instance variables.

Basic ShapeChanger:

To define a new ShapeChanger, you should subclass base StompShapeChanger and override two methods.

StompShapeChanger >> loadAdditions  Override the method for setting newly introduced field values to the shape changed instance. 
StompShapeChanger >> loadInstVarAt: varIndex named: varName put: varValue   Override the method for setting renamed fields to the shape changed instance.

To register a ShapeChanger, you can:

Object fromStomp: bytes setting: [:context |
    context
registerShapeChanger: YourShapeChanger for: YourShapeChangedClass ].
There is a StompMockShapeChanger in StompTest-Core package. Please see the running example.

Block ShapeChanger:

StOMP also supports BlockShapeChanger. You can register shape change procedures without subclassing StompShapeChanger.
Object fromStomp: bytes setting: [:context |
context
registerShapeChangerRenameBy: [:target :oldName :value | oldName = 'instVar2OLD' ifTrue: [target instVar2: value]. ] initializeBy: [:target | target instVar5: 'FIVE' ] for: YourShapeChangedClass ].



Comments