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]: Print via Desc - #maFullPrintString & Separator Config #335

Merged
Merged
Show file tree
Hide file tree
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
13 changes: 11 additions & 2 deletions source/Magritte-Model/MAContainer.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,16 @@ MAContainer >> postCopy [

{ #category : #accessing }
MAContainer >> print: anObject on: aStream [
"Print the current values of all anObject's described fields. Customize the printing of a field with the #maPrintString property, which should store a valuable with the value of the field as an optional argument"

"Print the current values of all anObject's described fields. Your can customize:
1) the printing of a field via the #maPrintString property, which should store a valuable with the value of the field as an optional argument
2) the field separator, via the maPrintStringSeparator property, which should store a valuable whose optional argument is the stream, and which should put separator thereon"

| separatorBlock |
separatorBlock := self
propertyAt: #maPrintStringSeparator
ifAbsent: [ [ aStream space ] ].

self
do: [ :d |
| value |
Expand All @@ -308,7 +317,7 @@ MAContainer >> print: anObject on: aStream [
ifPresent: [ :map | map cull: value ]
ifAbsent: [ d toString: value ].
aStream nextPutAll: stringValue ] ]
separatedBy: [ aStream space ]
separatedBy: [ separatorBlock cull: aStream ]
]

{ #category : #enumerating }
Expand Down
6 changes: 6 additions & 0 deletions source/Magritte-Model/Object.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ Object >> isSameAs: rhs using: valuableDescription [
"Motivation: We cache the description because profiling on a large dataset (120,000 records) showed about 66% of processing time was spent (re)building it"
]

{ #category : #'*Magritte-Model' }
Object >> maFullPrintString [

^ String streamContents: [ :str | self maPrintOn: str ]
]

{ #category : #'*Magritte-Model' }
Object >> maHash [
^ self maHashUsing: [ self magritteDescription ]
Expand Down
Loading