Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enh]: MAMessagingStringWriter #361

Conversation

seandenigris
Copy link
Member

Enables delegating string writing to an arbitrary object via any of its messages.

Limitation: cannot be used when 1) the message receiver is the container and 2) descriptions are cached e.g. when using the description for the first object in a homogeneous collection for the whole collection.

Here is an example (which illustrates No. 1 in the limitation above and so wouldn't work with a cached description):

MyDomainClass>>employeeDescription
	<magritteDescription>
	
	| message writer reference |
	message := MessageSend 
		receiver: self
		selector: #employeeDisplayString.
	
	writer := MAMessagingStringWriter new
		messageSend: message.
	
	reference := MAContainer new 
		stringWriter: writer;
		yourself.

	^ MAToOneRelationDescription new
		reference: reference;
		accessor: #employee;
		yourself

Enables delegating string writing to an arbitrary object via any of its messages. 

*Limitation:* cannot be used when 1) the message receiver is the container and 2) descriptions are cached e.g. when using the description for the first object in a homogeneous collection for the whole collection.

Here is an example (which illustrates #1 in the limitation above and so wouldn't work with a cached description):

```
MyDomainClass>>employeeDescription
	<magritteDescription>
	
	| message writer reference |
	message := MessageSend 
		receiver: self
		selector: #employeeDisplayString.
	
	writer := MAMessagingStringWriter new
		messageSend: message.
	
	reference := MAContainer new 
		stringWriter: writer;
		yourself.

	^ MAToOneRelationDescription new
		reference: reference;
		accessor: #employee;
		yourself
```
@seandenigris seandenigris merged commit 5b41060 into magritte-metamodel:master Aug 16, 2024
4 checks passed
@seandenigris seandenigris deleted the enh_messaging-string-writer branch August 16, 2024 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant