Module: Surrealist::Copier
- Defined in:
- lib/surrealist/copier.rb
Overview
A helper class for deep copying and wrapping hashes.
Class Method Summary collapse
-
.deep_copy(hash, wrapper = {}) ⇒ Hash
Goes through the hash recursively and deeply copies it.
Class Method Details
.deep_copy(hash, wrapper = {}) ⇒ Hash
Goes through the hash recursively and deeply copies it.
13 14 15 16 17 |
# 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 |