@@ -231,49 +231,41 @@ S7::method(plot, class_ggplot) <- `print.ggplot2::ggplot`
231
231
232
232
# The following extractors and subassignment operators are for a smooth
233
233
# transition and should be deprecated in the release cycle after 4.0.0
234
- # TODO: should convert to proper S7 method once bug in S7 is resolved
235
-
236
- # ' @export
237
- `$.ggplot2::gg` <- function (x , i ) {
238
- if (! S7 :: prop_exists(x , i ) && S7 :: prop_exists(x , " meta" )) {
239
- # This is a trick to bridge a gap between S3 and S7. We're allowing
240
- # for arbitrary fields by reading/writing to the 'meta' field when the
241
- # index does not point to an actual property.
242
- # The proper way to go about this is to implement new fields as properties
243
- # of a ggplot subclass.
244
- S7 :: prop(x , " meta" )[[i ]]
245
- } else {
246
- `[[`(S7 :: props(x ), i )
234
+ local({
235
+ S7 :: method(`[[` , class_gg ) <- S7 :: method(`$` , class_gg ) <-
236
+ function (x , i ) {
237
+ if (! S7 :: prop_exists(x , i ) && S7 :: prop_exists(x , " meta" )) {
238
+ # This is a trick to bridge a gap between S3 and S7. We're allowing
239
+ # for arbitrary fields by reading/writing to the 'meta' field when the
240
+ # index does not point to an actual property.
241
+ # The proper way to go about this is to implement new fields as properties
242
+ # of a ggplot subclass.
243
+ S7 :: prop(x , " meta" )[[i ]]
244
+ } else {
245
+ `[[`(S7 :: props(x ), i )
246
+ }
247
+ }
248
+ S7 :: method(`[` , class_gg ) <- function (x , i ) {
249
+ `[`(S7 :: props(x ), i )
247
250
}
248
- }
251
+ })
249
252
250
- # ' @export
251
- `$<-.ggplot2::gg` <- function (x , i , value ) {
252
- if (! S7 :: prop_exists(x , i ) && S7 :: prop_exists(x , " meta" )) {
253
- # See explanation in `$.ggplot2::gg`
254
- S7 :: prop(x , " meta" )[[i ]] <- value
255
- } else {
256
- S7 :: props(x ) <- `[[<-`(S7 :: props(x ), i , value )
253
+ local({
254
+ S7 :: method(`$<-` , class_gg ) <- S7 :: method(`[[<-` , class_gg ) <-
255
+ function (x , i , value ) {
256
+ if (! S7 :: prop_exists(x , i ) && S7 :: prop_exists(x , " meta" )) {
257
+ # See explanation in `$.ggplot2::gg`
258
+ S7 :: prop(x , " meta" )[[i ]] <- value
259
+ } else {
260
+ S7 :: props(x ) <- `[[<-`(S7 :: props(x ), i , value )
261
+ }
262
+ x
263
+ }
264
+ S7 :: method(`[<-` , class_gg ) <- function (x , i , value ) {
265
+ S7 :: props(x ) <- `[<-`(S7 :: props(x ), i , value )
266
+ x
257
267
}
258
- x
259
- }
260
-
261
- # ' @export
262
- `[.ggplot2::gg` <- function (x , i ) {
263
- `[`(S7 :: props(x ), i )
264
- }
265
-
266
- # ' @export
267
- `[<-.ggplot2::gg` <- function (x , i , value ) {
268
- S7 :: props(x ) <- `[<-`(S7 :: props(x ), i , value )
269
- x
270
- }
271
-
272
- # ' @export
273
- `[[.ggplot2::gg` <- `$.ggplot2::gg`
274
-
275
- # ' @export
276
- `[[<-.ggplot2::gg` <- `$<-.ggplot2::gg`
268
+ })
277
269
278
270
# ' @importFrom S7 convert
279
271
# S7 currently attaches the S3 method to the calling environment which gives `ggplot2:::as.list`
0 commit comments