module Surrealist::Copier
A helper class for deep copying and wrapping hashes.
Public Class Methods
deep_copy(hash, wrapper = {})
click to toggle source
Goes through the hash recursively and deeply copies it.
@param [Hash] hash the hash to be copied. @param [Hash] wrapper the wrapper of the resulting hash.
@return [Hash] deeply copied hash.
# File lib/surrealist/copier.rb, line 13 def deep_copy(hash, wrapper = {}) hash.each_with_object(wrapper) do |(key, value), new| new[key] = value.is_a?(Hash) ? deep_copy(value) : value end end