Skip to content

Commit 03157ef

Browse files
committed
Use S7::method() for class_mapping getters/setters
1 parent b47faa0 commit 03157ef

File tree

3 files changed

+14
-24
lines changed

3 files changed

+14
-24
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ Collate:
9393
'aes-group-order.R'
9494
'aes-linetype-size-shape.R'
9595
'aes-position.R'
96+
'all-classes.R'
9697
'compat-plyr.R'
9798
'utilities.R'
9899
'aes.R'
99-
'all-classes.R'
100100
'annotation-borders.R'
101101
'utilities-checks.R'
102102
'legend-draw.R'

NAMESPACE

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
S3method("$","ggplot2::theme")
44
S3method("$",ggproto)
55
S3method("$",ggproto_parent)
6-
S3method("$<-","ggplot2::mapping")
7-
S3method("[","ggplot2::mapping")
86
S3method("[",mapped_discrete)
9-
S3method("[<-","ggplot2::mapping")
107
S3method("[<-",mapped_discrete)
118
S3method("[[",ggproto)
12-
S3method("[[<-","ggplot2::mapping")
139
S3method(.DollarNames,ggproto)
1410
S3method(as.data.frame,mapped_discrete)
1511
S3method(as.list,ggproto)

R/aes.R

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' @include utilities.R compat-plyr.R
1+
#' @include utilities.R compat-plyr.R all-classes.R
22
NULL
33

44
#' Construct aesthetic mappings
@@ -147,25 +147,19 @@ new_aesthetic <- function(x, env = globalenv()) {
147147
invisible(x)
148148
}
149149

150-
# TODO: should convert to proper S7 method once bug in S7 is resolved
151-
#' @export
152-
"[.ggplot2::mapping" <- function(x, i, ...) {
153-
class_mapping(NextMethod())
154-
}
155150

156-
# If necessary coerce replacements to quosures for compatibility
157-
#' @export
158-
"[[<-.ggplot2::mapping" <- function(x, i, value) {
159-
class_mapping(NextMethod())
160-
}
161-
#' @export
162-
"$<-.ggplot2::mapping" <- function(x, i, value) {
163-
class_mapping(NextMethod())
164-
}
165-
#' @export
166-
"[<-.ggplot2::mapping" <- function(x, i, value) {
167-
class_mapping(NextMethod())
168-
}
151+
local({
152+
S7::method(`[`, class_mapping) <- function(x, i, ...) {
153+
class_mapping(`[`(S7::S7_data(x), i, ...))
154+
}
155+
S7::method(`$<-`, class_mapping) <- S7::method(`[[<-`, class_mapping) <-
156+
function(x, i, value) {
157+
class_mapping(`[[<-`(S7::S7_data(x), i, value))
158+
}
159+
S7::method(`[<-`, class_mapping) <- function(x, i, value) {
160+
class_mapping(`[<-`(S7::S7_data(x), i, value))
161+
}
162+
})
169163

170164
#' Standardise aesthetic names
171165
#'

0 commit comments

Comments
 (0)