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

[API Request] conditionnal add: on MooseAbstractGroup (and FMSlotMultivalueLink) #2530

Open
alkalinan opened this issue Apr 10, 2024 · 0 comments

Comments

@alkalinan
Copy link

In his current API implementation, the Moose API for MooseModel and MooseGroup does not let us add an entity and check if another instance is already inside its entity storage.

Current behavior

myMooseModel := MooseModel new. 
"assuming that MyMooseObj has an id attribute"

myMooseModel 
       add: (MyMooseObj new id: 555; name: 'Foo'; yourself).
myMooseModel entities." an OrderedCollection(a GLHProject #Foo)"

myMooseModel 
       addAll: {(MyMooseObj new id: 555; name: 'Foo'; yourself). (MyMooseObj new id: 444; name: 'Bar'; yourself) }.
myMooseModel entities." an OrderedCollection(a MyMooseObj #Foo a MyMooseObj #Foo a MyMooseObj #Bar)" 

Proposed API

myMooseModel := MooseModel new. 

myMooseModel 
       add: (MyMooseObj new id: 555; name: 'Foo'; yourself).
myMooseModel entities." an OrderedCollection(a GLHProject #Foo)"

"add:unless:"
myMooseModel 
   addAll: {(MyMooseObj new id: 555; name: 'Foo'; yourself). (MyMooseObj new id: 444; name: 'Bar'; yourself) } 
   unless: [:existing : new | existing id = new id].
myMooseModel entities." an OrderedCollection(a MyMooseObj #Foo a MyMooseObj #Bar)"

The implementation of add:unless: and addAll:unless: are available in this repository.

This API could also be implemented for FMSlotMultivalueLink like in the following extension

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

No branches or pull requests

1 participant