To construct and send a configure message
topic.configure(membership: ['a', 'b', 'c'], name: 'bob', some_id: 100)
Serialise to XML
<configure>
...
<props>
<membership type='array'>
<it type='string'>a</it>
...
</membership>
<name type='string'>bob</name>
<some_id type='integer'>100</some_id>
</props>
</configure>
Reconstruct message class from XML
message[:membership] will return ['a', 'b', 'c']
Introduce additional data model, e.g. OmfCommon::Prop, and DSL method to init such model
topic.configure(
membership: frcp_prop(['a', 'b', 'c'], op: 'union'),
name: 'bob',
some_id: 100
)
Where frcp_prop(['a', 'b', 'c'], op: 'union') init Prop object contains 'op' information.
By the time of serialisation, add additional attr accordingly.
<membership type='array' op='union'>
<it type='string'>a</it>
...
</membership>
Then reconstruct to message from XML
message[:membership] will return OmfCommon::Prop, which says data is ['a', 'b', 'c'] and operation is 'union'
Extend message class to store operation information. Message construction will become:
topic.configure(
{ membership: ['a', 'b', 'c'], name: 'bob', some_id: 100 },
{ union: [:membership, ...], assign: [:name, :some_id ...] }
)
Same serialisation as option 1.
When received the message and reconstruct. Message instance will have { union: [:membership, ...], assign: [:name, :some_id ...] }
Then message[:membership] will still simply return ['a', 'b', 'c'], to find out operation information, we can do
message.op(:membership)
and it shall return 'union'
Last improvement, common to both options is to pass operation information to RC dsl. E.g:
configure :membership do |res, value, op|
case op
when 'assign'
res.membership = value
when 'union'
res.memership += value
res.membership.uniq!
end
end