Skip to content

Commit

Permalink
make configs print better
Browse files Browse the repository at this point in the history
  • Loading branch information
nsheff committed Jun 14, 2018
1 parent c3480ef commit 9978f4e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
2 changes: 1 addition & 1 deletion R/loadConfig.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ loadConfig = function(filename=NULL, sp=NULL) {
return()
}

cfg = yaml::yaml.load_file(filename)
cfg = new("Config", yaml::yaml.load_file(filename))

if (is.null(cfg)) {
message("Config file not loaded.")
Expand Down
27 changes: 22 additions & 5 deletions R/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#' @slot config a list object holding contents of the config file
#'
#' @exportClass Project
setClass("Project", representation(
setClass("Project", slots = c(
file="character",
samples="data.frame",
config="list")
Expand All @@ -24,9 +24,26 @@ Project = function(file, samples=list(), config=list()) {
new("Project", file=file)
}

#' Config objects are specialized list objects
#'
#' @exportClass Config
setClass("Config", contains="list")


# Override the standard generic show function for our config-style lists
setMethod("show",
signature = "Project",
definition = function(object) {
signature="Config",
definition=function(object) {
message("PEP project object. Class: ", class(object))
printNestedList(object)
invisible(NULL)
}
)


setMethod("show",
signature="Project",
definition=function(object) {
message("PEP project object. Class: ", class(object))
message(" file: ", object@file)
message(" samples: ", NROW(object@samples))
Expand All @@ -42,11 +59,11 @@ setGeneric("config", function(object, ...) standardGeneric("config"))
setMethod("config",
signature = "Project",
definition = function(object) {
printNestedList(object@config)
invisible(object@config)
object@config
}
)


setGeneric("samples", function(object, ...) standardGeneric("samples"))

#' @export
Expand Down

0 comments on commit 9978f4e

Please sign in to comment.