R/fetch_methods.R

fetch_session <- function(key, group, internal = F){

  if(!internal){
    opt_tag <- "store.rsession"
  }else{
    opt_tag <- "store.internal"
  }

  lex <- options(opt_tag)[[1]]
  val <- NULL

  if(!missing(group)){

    key_in <- key

    lex_grp <- lex[[group]]

    if(is.null(lex_grp)){
      lex_grp <- list()
    }

    val <- lex_grp[[key_in]]

  }else{

    if(key %in% names(lex)){
      val <- lex[[key]]
    }

  }

  return(val)

}

fetch_local <- function(key, group, local_path){

  file_path <- get_local_file_path(group, local_path)

  val <- NULL

  if(file.exists(file_path)){

    lex <- readRDS(file_path)
    if(is.null(lex)){
      lex <- list()
    }

    val <- lex[[key]]

  }

  return(val)


}
MadeInR/store documentation built on May 12, 2019, 8:41 a.m.