Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: override clone method to only allow for deep clones #21

Open
akselthomsen opened this issue Jul 15, 2024 · 0 comments
Open

feat: override clone method to only allow for deep clones #21

akselthomsen opened this issue Jul 15, 2024 · 0 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@akselthomsen
Copy link
Contributor

Should we override the default clone method of a connector object to only allow for deep clones following the discussion in #18 ?

As of now a connector object remains cloneable, but with the default deep=FALSE.
So far two ways of changing this has been identified:

  1. Change the default value of the cloning method with:
    formals(connector$public_methods$clone)[["deep"]] <- TRUE
    Pro: Easy solution, and Rd documentation will still be correct
    Con: Confusing for experienced R6 users that the standard clone method has a different method

  2. Create a custom clone method for the connector object with only deep cloning available.
    One solution could be:
    connector$set("private", ".clone", connector$public_methods$clone, TRUE)
    connector$set("public", "clone", \() private$.clone(deep = TRUE), TRUE)
    Another could be to internalise the clone method and always have deep = TRUE.
    Pro: Robust, and only allows for deep clones
    Con: Cannot override the roxygen documentation, and might need us to have cloning under a new method name.

Useful references:

@akselthomsen akselthomsen added question Further information is requested enhancement New feature or request labels Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant