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

[Bug]: Property Owner Trait - Only Announce Change After Put #354

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions source/Magritte-Model/MATPropertyOwner.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -142,18 +142,20 @@ MATPropertyOwner >> propertyAt: aKey ifPresent: oneArgBlock ifAbsent: absentBloc
{ #category : #accessing }
MATPropertyOwner >> propertyAt: aKey ifPresent: oneArgBlock ifAbsentPut: absentBlock [
"Lookup ==aKey==, if it is present, answer the value of evaluating the oneArgBlock with the value associated with the key, otherwise answer the value of absentBlock."
| anOldValue aNewValue |
anOldValue := nil.
aNewValue := self properties

| aValue didPut |
didPut := false.
aValue := self properties
at: aKey
ifPresent: [ :aValue |
anOldValue := aValue.
oneArgBlock value ]
ifAbsentPut: absentBlock.
ifPresent: oneArgBlock
ifAbsentPut: [
didPut := true.
absentBlock value ].

self propertyAnnounceKey: aKey oldValue: anOldValue newValue: aNewValue.

^ aNewValue
didPut ifTrue: [
self propertyAnnounceKey: aKey oldValue: nil newValue: aValue ].

^ aValue
]

{ #category : #accessing }
Expand Down
Loading