Type checks - Determine object-oriented system of object
object_system.RdR has many object-oriented systems, including S3, S4, RC, R6, R.oo, S7,
proto, and ggproto. This function determines to which of these an object
belongs, extending the test done by sloop::otype().
If x fails is.object(), the function returns "base". x matches "S3"
if it is an object but does not match any other system, so systems not
implemented here will fall into that category.
is_system() tests if an object belongs to a specific system.
Value
[
character(1)] Forobject_system(): the object-oriented system ofx.[
TRUE|FALSE] Foris_system(): The scalar result of the test.
Details
The implemented check is as below:
If not
is.object(), return"base".Else, if
isS4(), return"RC"ifis(x, "refClass"), else return"S4".Else, if
inherits_any(x, "S7_object")andtypeof(x) == "object"(as an additional safeguard), return"S7".Else, if
inherits_any(x, "R6")andrlang::is_environment(), return"R6".Else, if
inherits_any(x, "ggproto")andrlang::is_environment(),return
"ggproto".Else, if
inherits_any(x, "proto")andall(c(".super", ".that") %in% names(x))andrlang::is_environment(), return"proto".Else, if
inherits_any(x, "Object")andall(c(".env", "...modifiers", "...finalize") %in% names(attributes(x)))andis_logical(x, 1), return"R.oo".