class ElasticAPM::Util::DeepDup
Array, String, Number, etc.
NB: Not guaranteed to work well with complex objects, only simple Hash,
Makes a deep copy of an Array or Hash
@api private
def self.dup(obj)
def self.dup(obj) new(obj).dup end
def array(arr)
def array(arr) arr.map { |obj| deep_dup(obj) } end
def deep_dup(obj)
def deep_dup(obj) case obj when Hash then hash(obj) when Array then array(obj) else obj.dup end end
def dup
def dup deep_dup(@obj) end
def hash(hsh)
def hash(hsh) result = hsh.dup hsh.each_pair do |key, value| result[key] = deep_dup(value) end result end
def initialize(obj)
def initialize(obj) @obj = obj end