Skip to content

Commit

Permalink
Merge pull request #680 from moosetechnology/isRoot-property
Browse files Browse the repository at this point in the history
Introduce #isRoot boolean property
  • Loading branch information
jecisc authored Jan 12, 2024
2 parents c4cce8b + 1bb11d0 commit 05c9962
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
11 changes: 0 additions & 11 deletions src/Moose-Core-Tests/MooseEntityTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ MooseEntityTest >> testBookmark [
self assert: bookmark isBookmarked
]

{ #category : #tests }
MooseEntityTest >> testIsRoot [
| entity |
entity := self actualClass new.
entity stub parents willReturn: { }.
self assert: entity isRoot.

entity stub parents willReturn: { MooseEntity new }.
self deny: entity isRoot
]

{ #category : #tests }
MooseEntityTest >> testIsStub [
self deny: self actualClass new isStub.
Expand Down
7 changes: 0 additions & 7 deletions src/Moose-Core/MooseEntity.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,6 @@ MooseEntity >> isMooseEntity [
^ true
]

{ #category : #testing }
MooseEntity >> isRoot [
"Return true if the entity is not contained in any other entity."

^ self parents isEmpty
]

{ #category : #testing }
MooseEntity >> isStub [
^ self attributeAt: #privateIsStub ifAbsent: [ false ]
Expand Down
10 changes: 10 additions & 0 deletions src/Moose-Query/TEntityMetaLevelDependency.trait.st
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,16 @@ TEntityMetaLevelDependency >> isIncludedIn: anEntity parentSelectorsCache: paren
^ false
]

{ #category : #testing }
TEntityMetaLevelDependency >> isRoot [

<FMProperty: #isRoot type: #Boolean>
<derived>
<FMComment:
'An entity is root if it has no parent in the model. This is useful for example to be able to build visualization where the displayed elements are the roots of the model and to let those elements be expanded to display their children.'>
^ self parents isEmpty
]

{ #category : #accessing }
TEntityMetaLevelDependency >> numberOfChildren [
<FMProperty: #numberOfChildren type: #Number>
Expand Down

0 comments on commit 05c9962

Please sign in to comment.