Skip to content

Commit

Permalink
[Enh]: Element Descriptions - Initial Answer
Browse files Browse the repository at this point in the history
Slightly different than `default`. Default is what the value of the field *is* if not explicitly set. The initial answer is what the value *might be* e.g. to make it easier to fill out a form.
  • Loading branch information
seandenigris committed Oct 21, 2023
1 parent ae35667 commit 23259d2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions source/Magritte-Model/MADescription.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,10 @@ MADescription >> undefined: aString [

{ #category : #'accessing-properties' }
MADescription >> undefinedValue [
self flag: 'could this be simplified with maLazyXyz?'.
^ (self propertyAt: #undefinedValue ifAbsent: [ self class defaultUndefinedValue ])
ifNil: [ self class defaultUndefinedValue ]

^ self
propertyAt: #undefinedValue
ifAbsent: [ self class defaultUndefinedValue ]
]

{ #category : #'accessing-properties' }
Expand Down
10 changes: 10 additions & 0 deletions source/Magritte-Model/MAElementDescription.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ MAElementDescription >> handlesSelector: aSelector [
^ self accessor handlesSelector: aSelector
]

{ #category : #accessing }
MAElementDescription >> initialAnswer [
^ self propertyAt: #initialAnswer ifAbsent: [ self default ]
]

{ #category : #accessing }
MAElementDescription >> initialAnswer: aValuable [
self propertyAt: #initialAnswer put: aValuable
]

{ #category : #'lazy initialization' }
MAElementDescription >> lazilyInitializeFrom: currentValue for: anObject [
"- The default value is cached if the description's #shouldCacheDefault property is true. An example when caching is necessary is for to-many relations because the user may modify the collection, which will then be thrown away if not cached
Expand Down

0 comments on commit 23259d2

Please sign in to comment.