Skip to content

Commit

Permalink
Merge branch 'main' into rstudio_addin
Browse files Browse the repository at this point in the history
  • Loading branch information
DSchreyer authored Nov 8, 2024
2 parents 0e0a0ad + 1ccb35e commit fabf1c5
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 48 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

- Removed ... in reload function


## v0.5.1

### Improvements

- Fixed `reload()` function for dsoParams

## v0.5.0

### New Features
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export(set_stage)
export(stage_here)
exportClasses(dsoParams)
exportMethods(as.list)
exportMethods(reload)
exportMethods(show)
importFrom(glue,glue)
importFrom(here,here)
Expand Down
28 changes: 1 addition & 27 deletions R/class-dsoParams.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,4 @@ setMethod(
}
})
}
)


#' @title reload function
#' @description
#' Generic function for reloading configurations.
#'
#' @param object dsoParams config object
#' @export
setGeneric("reload", function(object) standardGeneric("reload"))


#' @title reload dso params
#' @description
#' reloads the current dsoParams config into object
#'
#' @param object dsoParams object
#' @export
setMethod("reload", "dsoParams", function(object) {
if (!inherits(object, "dsoParams")) {
stop("The object is not of class 'dsoParams'")
}

object <<- read_params()

invisible(object)
})
)
2 changes: 1 addition & 1 deletion R/read_params.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ read_params <- function(stage_path = NULL, return_list = FALSE) {
if (is.null(config_env$stage_dir)) {
stop("stage_path argument missing.")
} else {
cat(paste("reloading from already set stage_path:", config_env$stage_dir))
message(glue::glue("Reloading from already set stage_path: {config_env$stage_dir}"))
stage_path <- config_env$stage_dir
}
}
Expand Down
17 changes: 17 additions & 0 deletions R/reload.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#' @title Reload dsoParams
#' @description
#' Reloads the current dsoParams configuration into the object.
#'
#' @param params dsoParams object
#' @param env environment in which object is located, caller_env() by default
#' @return The updated dsoParams object.
#' @export
reload <- function(params, env = caller_env()) {
if (!inherits(params, "dsoParams")) {
stop("The object is not of class 'dsoParams'")
}
var_name <- deparse(substitute(params))
assign(var_name, value = read_params(), envir = env)

invisible(get(var_name, envir = env))
}
14 changes: 0 additions & 14 deletions man/reload-dsoParams-method.Rd

This file was deleted.

15 changes: 10 additions & 5 deletions man/reload.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fabf1c5

Please sign in to comment.