@@ -13,7 +13,7 @@ find_scale <- function(aes, x, env = parent.frame()) {
1313 if (isTRUE(grepl(" ::" , scale ))) {
1414 # Append prefix as namepaces to search environments
1515 prefix <- sub(" ::.*" , " " , scale )
16- search_env <- c(search_env , list (asNamespace (prefix )))
16+ search_env <- c(search_env , list (as_namespace (prefix )))
1717 # Remove prefix from scale name
1818 scale <- sub(" .*::" , " " , scale )
1919 }
@@ -41,7 +41,7 @@ find_global <- function(name, env, mode = "any") {
4141 if (! is.list(env )) {
4242 env <- list (env )
4343 }
44- env <- c(env , list (asNamespace (" ggplot2" )))
44+ env <- c(env , list (as_namespace (" ggplot2" )))
4545
4646 for (e in env ) {
4747 if (exists(name , envir = e , mode = mode )) {
@@ -52,6 +52,13 @@ find_global <- function(name, env, mode = "any") {
5252 NULL
5353}
5454
55+ # This exists for testing purposes (mocking) only
56+ as_namespace <- function (... ) NULL
57+ on_load({
58+ as_namespace <- base :: asNamespace
59+ })
60+
61+
5562# ' Determine default scale type
5663# '
5764# ' You will need to define a method for this method if you want to extend
0 commit comments