Inversion::
DataUtilities
module
A collection of data-manipulation functions.
Recursively copy the specified ‘obj` and return the result.
def deep_copy( obj )
return obj if obj.class.name == 'RSpec::Mocks::Mock'
return case obj
when NilClass, Numeric, TrueClass, FalseClass, Symbol,
Module, Encoding, IO, Tempfile
obj
when Array
obj.map {|o| deep_copy(o) }
when Hash
newhash = {}
newhash.default_proc = obj.default_proc if obj.default_proc
obj.each do |k,v|
newhash[ deep_copy(k) ] = deep_copy( v )
end
newhash
else
obj.clone
end
end