lib/anyway/ext/deep_dup.rb in anyway_config-0.5.1.rc1 vs lib/anyway/ext/deep_dup.rb in anyway_config-0.5.1

- old
+ new

@@ -1,33 +1,21 @@ -# frozen_string_literal: true - module Anyway module Ext # Extend Object through refinements module DeepDup refine ::Hash do # Based on ActiveSupport http://api.rubyonrails.org/classes/Hash.html#method-i-deep_dup def deep_dup each_with_object(dup) do |(key, value), hash| - hash[key] = if value.is_a?(::Hash) || value.is_a?(::Array) - value.deep_dup - else - value - end + hash[key] = value.respond_to?(:deep_dup) ? value.deep_dup : value end end end refine ::Array do # From ActiveSupport http://api.rubyonrails.org/classes/Array.html#method-i-deep_dup def deep_dup - map do |value| - if value.is_a?(::Hash) || value.is_a?(::Array) - value.deep_dup - else - value - end - end + map { |el| el.respond_to?(:deep_dup) ? el.deep_dup : el } end end end end end