aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/hash/deep_dup.rb
blob: 9ab179c5668d09662f8f22cd272afc5371b64495 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
class Hash
  # Returns a deep copy of hash.
  def deep_dup
    duplicate = self.dup
    duplicate.each_pair do |k,v|
      duplicate[k] = v.is_a?(Hash) ? v.deep_dup : v
    end
    duplicate
  end
end