Bladeren bron

offer refactored way to remove subject collection

Bastien Sevajol 6 jaren geleden
bovenliggende
commit
b6ab205fb0
1 gewijzigde bestanden met toevoegingen van 7 en 0 verwijderingen
  1. 7 0
      synergine2/simulation.py

+ 7 - 0
synergine2/simulation.py Bestand weergeven

@@ -120,6 +120,13 @@ class Subject(IdentifiedObject):
120 120
         for collection in self.collections:
121 121
             self.simulation.collections.setdefault(collection, []).append(self.id)
122 122
 
123
+    def remove_collection(self, collection_name: str) -> None:
124
+        self.collections.remove(collection_name)
125
+        # Manipulate as shared property
126
+        simulation_collection = self.simulation.collections[collection_name]
127
+        simulation_collection.remove(self.id)
128
+        self.simulation.collections[collection_name] = simulation_collection
129
+
123 130
     def __str__(self):
124 131
         return self.__repr__()
125 132