Basically, I want to have an old instance of the variable after updating a variable
Here is some example that might explain better:
variable = { a: "#fff" }
saved = variable
variable[:a] = "#000"
saved[:a]
The goal is to get "#fff"
. Instead last line returns "#000"
which is expected. I tried freezing an object:
variable = { a: "#fff" }
saved = variable
saved.freeze
variable[:a] = "#000"
But that will just raise an FrozenError: can't modify frozen Hash
error