[squeak-dev] The Inbox: Kernel-cmm.761.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Jul 5 02:02:14 UTC 2013


A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-cmm.761.mcz

==================== Summary ====================

Name: Kernel-cmm.761
Author: cmm
Time: 4 July 2013, 9:01:30.236 pm
UUID: b9aaab83-9dfc-4c4f-a4e6-203167954cc1
Ancestors: Kernel-cmm.760

- Introduce AttributableObject, an abstract class whose subclass instances allow a variable number of attributes to be set and accessed at run time.

=============== Diff against Kernel-cmm.760 ===============

Item was added:
+ Object subclass: #AttributableObject
+ 	instanceVariableNames: 'attributes'
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'Kernel-Models'!
+ 
+ !AttributableObject commentStamp: 'cmm 10/7/2009 21:03' prior: 0!
+ Subclass from this abstract class to inherit an attribute Dictionary.!

Item was added:
+ ----- Method: AttributableObject>>attributeNamed: (in category 'attributes') -----
+ attributeNamed: aString 
+ 	^ attributes ifNotNil: 
+ 		[ attributes 
+ 			at: aString
+ 			ifAbsent: [ nil ] ]!

Item was added:
+ ----- Method: AttributableObject>>attributeNamed:put: (in category 'attributes') -----
+ attributeNamed: aString put: anObject 
+ 	anObject ifNotNil: [ attributes ifNil: [ attributes := Dictionary new ] ].
+ 	^ anObject
+ 		ifNil:
+ 			[ self removeAttributeNamed: aString.
+ 			anObject ]
+ 		ifNotNil:
+ 			[ attributes
+ 				at: aString
+ 				put: anObject ]!

Item was added:
+ ----- Method: AttributableObject>>attributesToDeepCopy (in category 'copying') -----
+ attributesToDeepCopy
+ 	"Subclasses override."
+ 	^ attributes
+ 		ifNil: [ Array empty ]
+ 		ifNotNil: [ attributes keys ]!

Item was added:
+ ----- Method: AttributableObject>>removeAttributeNamed: (in category 'attributes') -----
+ removeAttributeNamed: aString 
+ 	^ attributes ifNotNil: 
+ 		[ | answer |
+ 		answer := attributes 
+ 			removeKey: aString
+ 			ifAbsent: [ nil ].
+ 		attributes ifEmpty: [ attributes := nil ].
+ 		answer ]!

Item was added:
+ ----- Method: AttributableObject>>veryDeepInner: (in category 'copying') -----
+ veryDeepInner: aDeepCopier 
+ 	super veryDeepInner: aDeepCopier.
+ 	attributes := attributes copy.
+ 	self attributesToDeepCopy do:
+ 		[ : eachAttribute | attributes
+ 			at: eachAttribute
+ 			ifPresent:
+ 				[ : value | attributes
+ 					at: eachAttribute
+ 					put: (value veryDeepCopyWith: aDeepCopier) ]
+ 			ifAbsent: [ self error: eachAttribute, ' is not an attribute.' ] ]!



More information about the Squeak-dev mailing list