Skip to content

Commit 26cf386

Browse files
committed
condense more classes
1 parent f8325be commit 26cf386

File tree

11 files changed

+72
-60
lines changed

11 files changed

+72
-60
lines changed

R/class_frames.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ frames_init <- function(imports = memory_init()) {
44
}
55

66
frames_new <- function(imports = NULL, targets = NULL) {
7-
force(imports)
8-
force(targets)
9-
environment()
7+
out <- new.env(parent = emptyenv(), hash = FALSE)
8+
out$imports <- imports
9+
out$targets <- targets
10+
out
1011
}
1112

1213
frames_get_envir <- function(frames) {

R/class_group.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
group_new <- function(object = NULL) {
2-
enclass(environment(), c("tar_group", "tar_value"))
2+
out <- new.env(parent = emptyenv(), hash = FALSE)
3+
out$object <- object
4+
enclass(out, c("tar_group", "tar_value"))
35
}
46

57
#' @export

R/class_junction.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ junction_init <- function(
1010
}
1111

1212
junction_new <- function(nexus = NULL, splits = NULL, deps = NULL) {
13-
force(nexus)
14-
force(splits)
15-
force(deps)
16-
environment()
13+
out <- new.env(parent = emptyenv(), hash = FALSE)
14+
out$nexus <- nexus
15+
out$splits <- splits
16+
out$deps <- deps
17+
out
1718
}
1819

1920
junction_upstream_edges <- function(junction) {

R/class_list.R

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
list_new <- function(object = NULL) {
2-
enclass(environment(), c("tar_list", "tar_value"))
2+
out <- new.env(parent = emptyenv(), hash = FALSE)
3+
out$object <- object
4+
enclass(out, c("tar_list", "tar_value"))
35
}
46

57
#' @export

R/class_memory.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ memory_init <- function(envir = new.env(parent = emptyenv())) {
44
}
55

66
memory_new <- function(envir = NULL, names = NULL, count = NULL) {
7-
force(envir)
8-
force(names)
9-
force(count)
10-
environment()
7+
out <- new.env(parent = emptyenv(), hash = FALSE)
8+
out$envir <- envir
9+
out$names <- names
10+
out$count <- count
11+
out
1112
}
1213

1314
memory_exists_object <- function(memory, name) {

R/class_metrics.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ metrics_new <- function(
66
traceback = NULL,
77
cancel = NULL
88
) {
9-
force(seconds)
10-
force(warnings)
11-
force(error)
12-
force(error_class)
13-
force(traceback)
14-
force(cancel)
15-
environment()
9+
out <- new.env(parent = emptyenv(), hash = FALSE)
10+
out$seconds <- seconds
11+
out$warnings <- warnings
12+
out$error <- error
13+
out$error_class <- error_class
14+
out$traceback <- traceback
15+
out$cancel <- cancel
16+
out
1617
}
1718

1819
metrics_has_warnings <- function(metrics) {

R/class_pattern.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ pattern_new <- function(
66
junction = NULL,
77
patternview = NULL
88
) {
9-
force(command)
10-
force(settings)
11-
force(cue)
12-
force(value)
13-
force(junction)
14-
force(patternview)
15-
enclass(environment(), c("tar_pattern", "tar_target"))
9+
out <- new.env(parent = emptyenv(), hash = FALSE)
10+
out$command <- command
11+
out$settings <- settings
12+
out$cue <- cue
13+
out$value <- value
14+
out$junction <- junction
15+
out$patternview <- patternview
16+
enclass(out, c("tar_pattern", "tar_target"))
1617
}
1718

1819
#' @export

R/class_patternview.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ patternview_init <- function(seconds = 0, bytes = 0, progress = "queued") {
33
}
44

55
patternview_new <- function(seconds = 0, bytes = 0, progress = NULL) {
6-
force(seconds)
7-
force(bytes)
8-
force(progress)
9-
force(progress)
10-
environment()
6+
out <- new.env(parent = emptyenv(), hash = FALSE)
7+
out$seconds <- seconds
8+
out$bytes <- bytes
9+
out$progress <- progress
10+
out
1111
}
1212

1313
patternview_register_meta <- function(patternview, record) {

R/class_pedigree.R

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ pedigree_init <- function(parent, child, index) {
33
}
44

55
pedigree_new <- function(parent = NULL, child = NULL, index = NULL) {
6-
force(parent)
7-
force(child)
8-
force(index)
9-
environment()
6+
out <- new.env(parent = emptyenv(), hash = FALSE)
7+
out$parent <- parent
8+
out$child <- child
9+
out$index <- index
10+
out
1011
}
1112

1213
pedigree_validate <- function(pedigree) {

R/class_pipeline.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ pipeline_new <- function(
1515
loaded = NULL,
1616
transient = NULL
1717
) {
18-
force(targets)
19-
force(imports)
20-
force(loaded)
21-
force(transient)
22-
enclass(environment(), "tar_pipeline")
18+
out <- new.env(parent = emptyenv(), hash = FALSE)
19+
out$targets <- targets
20+
out$imports <- imports
21+
out$loaded <- loaded
22+
out$transient <- transient
23+
enclass(out, "tar_pipeline")
2324
}
2425

2526
pipeline_targets_init <- function(targets, clone_targets) {

0 commit comments

Comments
 (0)