Sha256: 7a58771389297c65a4694d90f0c46f2fdb2dfc48fa2093702f7b5a1f334ee51d

Contents?: true

Size: 844 Bytes

Versions: 5

Compression:

Stored size: 844 Bytes

Contents

# frozen_string_literal: true

# Taken from https://github.com/rails/rails/blob/83217025a171593547d1268651b446d3533e2019/activesupport/lib/active_support/core_ext/hash/deep_merge.rb

module LokaliseManager
  module Utils
    module HashUtils
      refine Hash do
        def deep_merge(other_hash, &block)
          dup.deep_merge!(other_hash, &block)
        end

        # Same as +deep_merge+, but modifies +self+.
        def deep_merge!(other_hash, &block)
          merge!(other_hash) do |key, this_val, other_val|
            if this_val.is_a?(Hash) && other_val.is_a?(Hash)
              this_val.deep_merge(other_val, &block)
            elsif block
              yield(key, this_val, other_val)
            else
              other_val
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lokalise_manager-2.2.1 lib/lokalise_manager/utils/hash_utils.rb
lokalise_manager-2.2.0 lib/lokalise_manager/utils/hash_utils.rb
lokalise_manager-2.1.0 lib/lokalise_manager/utils/hash_utils.rb
lokalise_manager-2.0.0 lib/lokalise_manager/utils/hash_utils.rb
lokalise_manager-1.2.1 lib/lokalise_manager/utils/hash_utils.rb