Search code examples
rubychef-infradeep-copy

How to do ruby deep copy in chef


I want to deep copy a chef attribute.

I try to use Marshal:

default[:deep_clone_test] = {};
Marshal.load(Marshal.dump(default[:deep_clone_test]))

But I get the error: "TypeError: can't dump hash with default proc"

How can I deep copy a chef attribute?


Solution

  • I ended doing this:

    JSON.parse(my_json.to_json, symbolize_names: true)