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

Memoize Question: DUP vs. Clone #33

Open
tjchambers opened this issue May 19, 2015 · 2 comments
Open

Memoize Question: DUP vs. Clone #33

tjchambers opened this issue May 19, 2015 · 2 comments

Comments

@tjchambers
Copy link

I was using Adamantium to help drive some immutability into my code, and noted a key issue in testing.

I was memoizing under Adamantium::Flat a result from another class that was returning an ActiveRecord model object (a single one). Because Adamantium uses a .dup method before freezing, the result is the ActiveRecord object has the ID removed.

My understanding is that using a clone method to replicate before freezing would preserve the ID (a crucial element for me). I know there are subtle differences between the two methods (not sure all of them - one of which is clone preserves previously frozen state - probably not relevant here).

My question is by using dup method instead of clone s this a bug or an intention?

@tjchambers
Copy link
Author

I neglected to point out that I was able to work around my issue by freezing my returned ActiveRecord object - so my question is more for consideration than a roadblock. It was unexpected behavior however and confused me for a bit.

@tjchambers
Copy link
Author

ping

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant