You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
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.
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?
The text was updated successfully, but these errors were encountered: