Looking for a STON in/out "factory"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Looking for a STON in/out "factory"

ducasse
Hi

I would like to use STON to save objects that non programmer will edit.
From that perspective I would like to be able to have a different class name
than the one in the implementation.

For example
instead of

'SQOne{#question:''Where do developers typically write the Pharo syntax?'',#choices:[''a stamp'',''an envelop'',''a postcard''],#solution:3,#explanation:''It is common to say that the Pharo syntax fits on a postcard.’'}

having

‘OneChoice{#question:''Where do developers typically write the Pharo syntax?'',#choices:[''a stamp'',''an envelop'',''a postcard''],#solution:3,#explanation:''It is common to say that the Pharo syntax fits on a postcard.’'}

I’m wondering if
        - there are hooks for that in STON so that I can inject a map. I look super fast at the doc
        and browsing the code and I could not find them.
        - if someone build such kind of layers on top of STON

Stef

Reply | Threaded
Open this post in threaded view
|

Re: Looking for a STON in/out "factory"

Sven Van Caekenberghe-2
That is already provided, you should implement

SQOne class>>#stonName
  ^ #OneChoice

Apart from that I would also use STON class>>#toStringPretty: or #prettyPrint: true on a writer, if the target audience are humans.

> On 20 Feb 2019, at 11:00, ducasse <[hidden email]> wrote:
>
> Hi
>
> I would like to use STON to save objects that non programmer will edit.
> From that perspective I would like to be able to have a different class name
> than the one in the implementation.
>
> For example
> instead of
>
> 'SQOne{#question:''Where do developers typically write the Pharo syntax?'',#choices:[''a stamp'',''an envelop'',''a postcard''],#solution:3,#explanation:''It is common to say that the Pharo syntax fits on a postcard.’'}
>
> having
>
> ‘OneChoice{#question:''Where do developers typically write the Pharo syntax?'',#choices:[''a stamp'',''an envelop'',''a postcard''],#solution:3,#explanation:''It is common to say that the Pharo syntax fits on a postcard.’'}
>
> I’m wondering if
> - there are hooks for that in STON so that I can inject a map. I look super fast at the doc
> and browsing the code and I could not find them.
> - if someone build such kind of layers on top of STON
>
> Stef
>


Reply | Threaded
Open this post in threaded view
|

Re: Looking for a STON in/out "factory"

CyrilFerlicot
In reply to this post by ducasse
On Wed, Feb 20, 2019 at 11:01 AM ducasse <[hidden email]> wrote:

>
> Hi
>
> I would like to use STON to save objects that non programmer will edit.
> From that perspective I would like to be able to have a different class name
> than the one in the implementation.
>
> For example
> instead of
>
> 'SQOne{#question:''Where do developers typically write the Pharo syntax?'',#choices:[''a stamp'',''an envelop'',''a postcard''],#solution:3,#explanation:''It is common to say that the Pharo syntax fits on a postcard.’'}
>
> having
>
> ‘OneChoice{#question:''Where do developers typically write the Pharo syntax?'',#choices:[''a stamp'',''an envelop'',''a postcard''],#solution:3,#explanation:''It is common to say that the Pharo syntax fits on a postcard.’'}
>

Hi Steph,

In the class side of your class you need to override the method #stonName.

> I’m wondering if
>         - there are hooks for that in STON so that I can inject a map. I look super fast at the doc
>         and browsing the code and I could not find them.
>         - if someone build such kind of layers on top of STON
>
> Stef
>


--
Cyril Ferlicot
https://ferlicot.fr