Add method to clean up object once garbage collected
[loomr.git] / R / loom.R
index 8bbbca98afb7e0d9fc694de76caed272268eadfd..2fdd8b7904778a3d9103ba54a7d26413eef42491 100644 (file)
--- a/R/loom.R
+++ b/R/loom.R
@@ -128,6 +128,9 @@ loom <- R6Class(
         self$version <- as.character(x = packageVersion(pkg = 'loomR'))
       }
     },
+    finalizer = function() {
+      self$close_all(close_self = TRUE)
+    }
     # Addding attributes and layers
     add.layer = function(layers, overwrite = FALSE) {
       if (self$mode == 'r') {