Module: BatchApi::Utils

Defined in:
lib/batch_api/utils.rb

Class Method Summary collapse

Class Method Details

.deep_dup(object) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/batch_api/utils.rb', line 4

def self.deep_dup(object)
  if object.is_a?(Hash)
    duplicate = object.dup
    duplicate.each_pair do |k,v|
      tv = duplicate[k]
      duplicate[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? deep_dup(tv) : v
    end
    duplicate
  else
    object
  end
end