Skip to content

Commit e7e08d5

Browse files
committed
put convert into local() too
1 parent 29e08d3 commit e7e08d5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

R/plot.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,14 +276,14 @@ S7::method(plot, class_ggplot) <- `print.ggplot2::ggplot`
276276
`[[<-.ggplot2::gg` <- `$<-.ggplot2::gg`
277277

278278
#' @importFrom S7 convert
279-
S7::method(convert, list(from = class_ggplot, to = S7::class_list)) <-
280-
function(from, to) {
281-
S7::props(from)
282-
}
283-
rm(`convert`)
284-
285279
# S7 currently attaches the S3 method to the calling environment which gives `ggplot2:::as.list`
286280
# Wrap in `local()` to provide a temp environment which throws away the attachment
287281
local({
288-
S7::method(as.list, class_ggplot) <- function(x, ...) convert(x, S7::class_list)
282+
S7::method(convert, list(from = class_ggplot, to = S7::class_list)) <-
283+
function(from, to) {
284+
S7::props(from)
285+
}
286+
287+
S7::method(as.list, class_ggplot) <-
288+
function(x, ...) convert(x, S7::class_list)
289289
})

0 commit comments

Comments
 (0)