Changelog
Source:NEWS.md
s7x (development version)
The scalar property presets
class_integerandclass_doubleare renamed toclass_intandclass_floatso they no longer maskS7::class_integerandS7::class_double.as_vector()gains methods for bare lists and for everything else. A list is coerced elementwise, so a structure mixing S7 objects with plain values converts in one call, and the generic is now total rather than erroring on an ordinary value.as_vector()no longer descends into adata.frame, which stripped its class and flipped it columnar. Recursion is now limited to bare lists.Added
enum_roclet(), a roxygen2 roclet that documents every exportednew_enum()class from the class itself, filling in the title, description,valueargument, andvariants/allow_naproperties. Enable it withRoxygen: list(roclets = c("collate", "namespace", "s7x::enum_roclet")). Tags written by hand are left alone.Classes created by
new_enum()now build their constructor with the default value substituted into the formals, so roxygen2 rendersColor(value = "Red")instead of leaking an internal variable name into the\usagesection.Added
to_json(), a generic that serializes an S7 object to a JSON string viaas_vector()andyyjsonr::write_json_str().as_vector()now recurses into S7 objects nested inside list properties (e.g.list(SomeS7Object, ...)), not just properties that are directly an S7 object.property_range()andproperty_range_discrete()now default to a typedNAwhenallow_na = TRUE(the default) and the property is omitted from a constructor call.property_union(..., default = NULL)now resolves to an actualNULLdefault regardless of where a literalNULLmember sits among..., instead of only whenNULLis listed first.property_union()now distinguishes an omitteddefaultfrom an explicitdefault = NULL: omittingdefaultstill derives one from a member’s own default, whiledefault = NULLpins the default toNULLand opts out of derivation.property_union()now derives its default from the first member’s own default (when a member is anS7_propertyand that default satisfies the union), instead of always defaulting toNULL.class_string,class_integer,class_double, andclass_booleannow default to a typedNAwhen omitted from a constructor call.new_enum()gains adefaultargument to pin a specific variant as the default, andallow_na = TRUEnow gives omitted enum properties a default ofNA.Added a Claude Code skill (
inst/skills/SKILL.md) documenting how to use s7x’s property helpers when writing S7 classes.new_enum()gains anallow_naargument (defaultTRUE) so enum values can beNA_character_.Added
class_boolean, a scalar logical property preset alongsideclass_string,class_integer, andclass_double.Added
as_vector(), a generic that coerces an S7 object to a plain R vector: an atomic vector for scalar-backed classes likeEnum, or a named list of (recursively coerced) properties for compound classes.