Module: HelpfulUtils::CoreExt::Hash

Included in:
Hash
Defined in:
lib/helpful_utils/core_ext/hash.rb

Instance Method Summary collapse

Instance Method Details

#clone_by_someway(value) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/helpful_utils/core_ext/hash.rb', line 12

def clone_by_someway(value)
  return value if value.is_a?(Symbol)
  if value.respond_to?(:deep_clone)
    value.deep_clone
  else
    value.clone
  end
end

#deep_cloneObject



4
5
6
7
8
9
10
# File 'lib/helpful_utils/core_ext/hash.rb', line 4

def deep_clone
  hash = {}
  self.each_pair do |key, value|
    hash.merge!({clone_by_someway(key)=>clone_by_someway(value)})
  end
  hash
end