Skip to content

Commit bfa8390

Browse files
committed
feat: initial support for names(teal_data)
1 parent b883c9a commit bfa8390

File tree

5 files changed

+88
-1
lines changed

5 files changed

+88
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Collate:
6363
'qenv-get_var.R'
6464
'qenv-get_warnings.R'
6565
'qenv-join.R'
66+
'qenv-names.R'
6667
'qenv-show.R'
6768
'qenv-within.R'
6869
'teal.code-package.R'

NAMESPACE

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Generated by roxygen2: do not edit by hand
22

33
S3method("[[",qenv.error)
4+
S3method("names<-",qenv)
5+
S3method("names<-",qenv.error)
6+
S3method(names,qenv)
7+
S3method(names,qenv.error)
48
S3method(within,qenv)
59
S3method(within,qenv.error)
610
export(concat)

R/qenv-eval_code.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ setMethod("eval_code", signature = c("qenv", "character"), function(object, code
8080
}
8181
}
8282

83-
8483
object@warnings <- c(object@warnings, current_warnings)
8584
object@messages <- c(object@messages, current_messages)
8685

R/qenv-names.R

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#' The Names of a `qenv` or `qenv_error` Object
2+
#'
3+
#' Functions to get the names of a `qenv` or `qenv_error` object.
4+
#' The names are extrapolated from the objects in the `qenv` environment and
5+
#' are not stored statically, unlike the normal behavior of `names()` function.
6+
#'
7+
#' Objects named with a `.` (dot) prefix will be ignored and not returned,
8+
#' unless `all.names` parameter is set to `TRUE`.
9+
#'
10+
#' @param x A (`qenv` or `qenv_error`) object.
11+
#' @param all.names (`logical(1)`) that specifies whether to include hidden
12+
#' objects.
13+
#' @param value Does nothing as the names assignment is not supported.
14+
#'
15+
#' @return A character vector of names.
16+
#'
17+
#' @seealso [base::names()]
18+
#'
19+
#' @export
20+
names.qenv <- function(x, all.names = FALSE) {
21+
checkmate::assert_flag(all.names)
22+
ls(get_env(x), all.names = all.names)
23+
}
24+
25+
#' @rdname names.qenv
26+
#' @export
27+
names.qenv.error <- function(x, all.names = FALSE) {
28+
NULL
29+
}
30+
31+
#' @rdname names.qenv
32+
#' @export
33+
`names<-.qenv` <- function(x, value) {
34+
warning("`names(x) <- value` assignment does nothing for qenv objects")
35+
x
36+
}
37+
38+
#' @rdname names.qenv
39+
#' @export
40+
`names<-.qenv.error` <- function(x, value) {
41+
warning("`names(x) <- value` assignment does nothing for qenv.error objects")
42+
x
43+
}

man/names.qenv.Rd

Lines changed: 40 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)