Skip to content

Commit

Permalink
Refactor quoted_call to not obscure so much
Browse files Browse the repository at this point in the history
  • Loading branch information
asardaes committed Jun 22, 2024
1 parent 909b082 commit 239db33
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/check-non-master.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag.
# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions
on:
push:
branches-ignore:
- master
pull_request:
branches:
- master
Expand Down
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ importFrom(reshape2,melt)
importFrom(rlang,"!!!")
importFrom(rlang,.data)
importFrom(rlang,as_environment)
importFrom(rlang,as_string)
importFrom(rlang,enexpr)
importFrom(rlang,enexprs)
importFrom(rlang,env_bind)
importFrom(rlang,exprs)
importFrom(rlang,is_call)
importFrom(rlang,list2)
importFrom(rlang,syms)
importFrom(shiny,runApp)
Expand Down
18 changes: 16 additions & 2 deletions R/UTILS-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,23 @@ get_from_callers <- function(obj_name, mode = "any") {
}

#' @importFrom rlang as_environment
#' @importFrom rlang as_string
#' @importFrom rlang enexpr
#' @importFrom rlang is_call
quoted_call <- function(fun, ..., dots = NULL) {
parent <- rlang::as_environment(list(.fun_ = match.fun(fun)), parent = parent.frame())
do_call(".fun_", enlist(..., dots = dots), parent = parent)
fun_expr <- rlang::enexpr(fun)
fun_name <- if (rlang::is_call(fun_expr)) {
fn <- as.character(fun_expr)
paste0(fn[2L], fn[1L], fn[3L], collapse = "")
} else {
rlang::as_string(fun_expr)
}
fun_name <- gsub("[@$:]", "_", fun_name)

l <- list(match.fun(fun))
names(l) <- fun_name
parent <- rlang::as_environment(l, parent = parent.frame())
do_call(fun_name, enlist(..., dots = dots), parent = parent)
}

#' @importFrom rlang as_environment
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/unit/methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ test_that("Methods for TSClusters objects are dispatched correctly.", {
info = "Plotting series and centroids providing data returns a gg object invisibly")
expect_true(inherits(plot(fuzzy_object, type = "series", plot = FALSE, labels = list()), "ggplot"),
info = "Plotting multivariate series returns a gg object invisibly")
expect_s3_class(plot(tadpole_object, plot = FALSE, size = 1.5), "ggplot")
expect_s3_class(plot(tadpole_object, plot = FALSE, linewidth = 1.5), "ggplot")

object_with_repeated_series <- partitional_object
object_with_repeated_series@datalist[[1L]] <- object_with_repeated_series@datalist[[2L]]
Expand Down

0 comments on commit 239db33

Please sign in to comment.