> On 17 May 2017, at 14:38, Cyril Ferlicot D. <cyril.ferli...@gmail.com> wrote:
> 
> On 17/05/2017 14:22, Sven Van Caekenberghe wrote:
>> 
>> Of course that does not work, it is your job to do something similar that 
>> fits your use case. You certainly do not have to cache everything.
>> 
>> On the other had, if you only serialise part of an object, or just one 
>> reference (id, url, name) like in the example, how will you recreate the 
>> rest, unless you have access to it ? And that is what your version of 
>> #fromId: should do.
>> 
>> I can't understand how your 'to export from an image and to load from 
>> another' can possibly work, unless there is some other way of sharing the 
>> data.
>> 
>> But I probably don't understand you, I known nothing about Moose models.
>> 
> 
> What I would like to know is if there is a simple way to customize the
> export of only one or two of the variables. And let the other variables
> be exported as usual.

The use of #stonAllInstVarNames works in limiting what you write out (there is 
even a unit test based on STONTestUser3).

But you seem to want to do something else, you want to write the others ones 
out in a different way.

What I tried to explain is that that is generally not needed, if you customise 
the value of #variableToCustomise (that is one level deeper). This is what I 
did in the example.

Since you can't or won't explain your use case better, I really can't help, can 
I ?

> I think I can do something like (I did not test but the spirit is here):
> 
> myObject class>>stonAllInstVarNames
>       ^ super stonAllInstVarNames \ { #variableToCustomise }
> 
> 
> myObject>>stonOn: stonWriter
> 
>  stonWriter writeObject: self streamMap: [ :dictionary |
>    self class stonAllInstVarNames do: [ :each |
>      (self instVarNamed: each)
>        ifNotNil: [ :value | dictionary at: each asSymbol put: value ]
>        ifNil: [ self stonShouldWriteNilInstVars ifTrue: [
>          dictionary at: each asSymbol put: nil ] ] ].
>    dictionary at: #variableToCustomize put: (self instVarNamed:
> #variableToCustomize) asString. ]
> 
> 
> myObject class>>fromSton: stonReader
> 
>  | obj |
>  obj := super fromSton: stonReader.
>  obj variableToCustomize: (UUID fromString: obj variableToCustomize)
>  ^ obj
> 
> But this imply to rewrite inside #stonOn: a part of the code used in the
> super stonOn: and I don't really like this in general.
> 
> So I wanted to know if there was a hook to customize certain variables
> while exporting the other as usual.
> 
> -- 
> Cyril Ferlicot
> https://ferlicot.fr
> 
> http://www.synectique.eu
> 2 rue Jacques Prévert 01,
> 59650 Villeneuve d'ascq France
> 


Reply via email to