gtoolkit icon indicating copy to clipboard operation
gtoolkit copied to clipboard

[Lepiter]: Page Type Updating Should Be Repeatable, Handle All Subclasses

Open seandenigris opened this issue 3 years ago • 1 comments

Situation: I have two custom page types which inherit from one another. Problems:

  1. the subclass is currently not recognized by GT
  2. when developing new page types, it is currently not easy to make existing DBs aware of them.

Currently:

LeDatabase>>#initialize
"..."
	LePageType subclassesDo: [ :pageType |
		pagesByType
			at: pageType pageTypeClass
			ifAbsentPut: [ Dictionary new ] ].
"..."

Solutions:

  1. should be: LePageType allSubclassesDo:
  2. Excerpted code should be extracted into its own method to be sent at other-than-intialization-time e.g.:
LeDatabase>>#updatePageTypes
	LePageType allSubclassesDo: [ :pageType |
		pagesByType
			at: pageType pageTypeClass
			ifAbsentPut: [ Dictionary new ] ].

seandenigris avatar May 18 '22 13:05 seandenigris

The behavior of LeDatabase>>#initialize currently calls allSubclassesDo:. Furthermore, my PR introduces this in LePageType class>>#initialize. In your custom page type you just need to have a class side initialize and that logic will be called on the super call.

As with other class initialization code, independent of Lepiter, you do have to call it manually when originally developing locally. Once it's in source control and loaded with Metacello this code gets run automatcially, no way around the original manual part though.

botwhytho avatar Apr 30 '25 19:04 botwhytho

The update of page types uses now allSubclassesDo:

chisandrei avatar Oct 09 '25 12:10 chisandrei

Thanks! I see my updatePageTypes made it in as populatePageTypes, so I can update my initialization code. I also really like @botwhytho moving it into page type initialization - that should be the final piece to make this straightforward.

seandenigris avatar Oct 10 '25 14:10 seandenigris