Method: Graphiti::Util::Hash.deep_dup
- Defined in:
- lib/graphiti/util/hash.rb
.deep_dup(hash) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Like ActiveSupport’s #deep_dup
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/graphiti/util/hash.rb', line 52 def self.deep_dup(hash) if hash.respond_to?(:deep_dup) hash.deep_dup else {}.tap do |duped| hash.each_pair do |key, value| value = deep_dup(value) if value.is_a?(Hash) value = value.dup if value&.respond_to?(:dup) && ![Symbol, Integer].include?(value.class) duped[key] = value end end end end |