The function new_rtoi() calls itself when the records argument is supplied, producing a stack usage error. I post below an indicative solution (my comments start with ###).
#' @rdname new_rtoi
#' @aliases character,sf,character,character,records
setMethod(
"new_rtoi",
signature(
name = "character",
region = "sf",
rtoi_path = "character",
db_path = "character",
records = "records",
size = "missing"
),
function(name, region, rtoi_path, db_path, records) {
newobj <- new_rtoi(name, region, rtoi_path, db_path, records = records) ### remove records = records
newobj$records <- records ### add this line
newobj$size <- 0
write_rtoi(newobj)
return(newobj)
}
)